<%= link_to image_tag(product.url), :action => :add_to_cart, :method =>
:delete, :id => product %>
Hi,
Did I implement this link correctly to send an HTTP Post request?
Thanks
<%= link_to image_tag(product.url), :action => :add_to_cart, :method =>
:delete, :id => product %>
Hi,
Did I implement this link correctly to send an HTTP Post request?
Thanks
Looks good if you want the http protocol to be delete… I think what
you want is :method => :post
:method => symbol of HTTP verb - This modifier will dynamically create
an HTML form and immediately submit the form for processing using the
HTTP verb specified. Useful for having links perform a POST operation
in dangerous actions like deleting a record (which search bots can
follow while spidering your site). Supported verbs are :post, :delete
and :put. Note that if the user has JavaScript disabled, the request
will fall back to using GET. If you are relying on the POST behavior,
you should check for it in your controller‘s action by using the
request object‘s methods for post?, delete? or put?.
If you are relying on the POST behavior,
you should check for it in your controller�s action by using the
request object�s methods for post?, delete? or put?.
I don’t understand that =) Can you explain in more detail please
Also, I’m trying to use sessions in my database…but after I did rake
db:sessions:create, rake db:migrate, I got this error:
ActionController::InvalidAuthenticityToken in Store#index
Showing store/index.html.erb where line #9 raised:
No :secret given to the #protect_from_forgery call. Set that or use a
session store capable of generating its own keys (Cookie Session Store).
Extracted source (around line #9):
6:
Thanks for the help!
Hi Justin,
Justin To wrote:
Also, I’m trying to use sessions in my database…but after I did
rake db:sessions:create, rake db:migrate, I got this error:ActionController::InvalidAuthenticityToken in Store#index
Showing store/index.html.erb where line #9 raised:
No :secret given to the #protect_from_forgery call. Set that or use a
session store capable of generating its own keys (Cookie Session Store).
Did you change the settin in environment.rb?
HTH,
Bill
I figured it out: named the file wrong. I’m new, so I’m unfamiliar with
the rails conventions.
Thanks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs