<%= 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: <h3><%=h product.title %></h3> 7: <%= product.description %><br /> 8: <span class="price"><%= number_to_currency(product.price) %></span> 9: <%= button_to("Add to Cart", :action => :add_to_cart, :id => product) %> 10: <br /> <br /> <br /> 11: </div> 12: <% end %>
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