It seems like I either have to hack prototype to make it include the
authenticity token somehow (doesn’t sound very appealing to me) or I
make rails not check the authenticity_token for that action (which I
dunno how to do and which would probably not be the best idea from a
security point of view)
any idea if this works when I list multiple resources on the same
page?
For example, I have a project which has multiple stores and multiple
products, and needs a description per product per store. So I need to
pass the controller a store id and a product id, and then find the
description which matches or, alternatively, create one if one doesn’t
exist.
From what I saw by just quickly looking at it this won’t work with my
problem
That will make your authenticity token available to your custom
javascript Ajax requests. If you’re using prototype.js and you want to
do a custom PUT, you do something like this.
new Ajax.Request (’/products/1’, {
method: ‘put’,
parameters: ‘product[name]=chair&authenticity_token=’ +
window._token});
You can do something like this in your view to make your authenticity
Thank you for that David. I have seen several questions around this
but afik yours is the first example of exactly how to include the
token in a js call - I’ll give it a go.
and, to make it work in test environment (where requests forgery
protection is disabled by default),
<%= javascript_tag “window._token = ‘#{form_authenticity_token}’” if
ActionController::Base.allow_forgery_protection %>
You can also use the form_authenticity_token() function do generate it.
Like :
I just wanted to say THANK YOU for posting about
form_autheticity_token()!!! Being new to ruby/rails, I’m not used to a
lot of the methods or procedures used within the framework. I was stuck
on trying to od a simple search when this saved me.
Hi
I m facing ActionController::InvalidAuthenticityToken problem.
i m trying to communicate two WEBrick Server with Different port.
I have 2 application
Service
Operation
service is running on 3000 port no and operation is running on 4000
port no
and i m trying to get the action of 3000 port from 4000 port. but
when i
trying i m get this error . could any body help me please