| |
Low Pro |
I have added the following that now works, except for the reload which
var AJ =
authenticity_token_query_parameter_for_page:function()
this._makeRequest( options );
respond_to do |wants|
On 24 Jan, 23:05, Jarkko Laine <jar...@jlaine.net> wrote:
> > Jarkko is correct, I am trying to create both an accessible link (when
> > After reading your post, I just thought to check my log to see if it
> This is the new csrf killer in action :-)
> You must pass the authenticity token to the link somehow (seehttp://edgedocs.planetargon.org/classes/ActionController/RequestForge...)
> Seehttp://edgedocs.planetargon.org/classes/ActionView/Helpers/UrlHelper....
> --
does not appear to be working as I intended. For completeness, I have
included my updated delete method.
{
encode_authenticity_token:function( token )
{
return encodeURIComponent( $(token).value )
},
{
return 'authenticity_token=' + AJ.encode_authenticity_token(
document.body.select( 'input[ name = "authenticity_token" ]' )
[ 0 ] )
}
{
onclick: function( event )
{
if ( confirm( 'Are you sure?' ) )
{
var options =
{
url: this.element.href.gsub( '/delete$', '' ),
method: 'delete',
parameters:
AJ.authenticity_token_query_parameter_for_page()
};
options = Object.extend( options, this.options );
Event.addBehavior.reload();
}
return false;
}
item = Item.find( params[ :id ] )
item.destroy
wants.html do
redirect_to item_path
end
wants.js do
@items = Item.find(:all)
render
end
end
end
> > Javascript is disabled) and an AJAX request when java is enabled.
> > showed anything. It does route but shows an
> > ActionController::InvalidAuthenticityToken during a call to
> > request_forgery_protection.
> . You could for example set a header for it in the controller and then
> set the form parameter in your behaviour according to that header.
> (click "Source") for how the Rails JS helpers populate the token in
> link_to_remote.
> Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce....