jquery - Devise session immediately expiring on .js call [AJAX] -


through trial , error, have narrowed problem down line 5 below. reason, .js response ending user session. using 3.0.4 , devise 1.1.7 (and jquery 1.5).

additionally, @organization being updated , completed 200 ok shows in log, user no know he/she logged out until next action attempted.

any , guidance appreciated.

*controller* 1   def make_featured 2     @organization = organization.find(params[:id]) 3     @organization.is_featured ? @organization.update_attribute(:is_featured,"false") :   @organization.update_attribute(:is_featured,"true") 4       respond_to |format| 5         format.js {render :action => "update", :layout => false} 6       end 7   end 

and

*update.js.haml* $("#organization_" + "#{@organization.id}" ).replacewith("#{ escape_javascript(render :partial => 'users/supplier_view', :locals => {:organization => @organization}) }"); 

many brandon martin devise google group pointing me int right direction...

this result of rails 3.0.4 security fix.

http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails

after hour or of working forward blog post, here tips others...

  • this has been fixed in rails.js - don't have hack, patch, or reinvent wheel.
  • if using rails.js out of box, update - rake rails:update (i think, use customized rails.js file)
  • if using custom rails.js file, go source code newest version here: https://github.com/fermion/jquery-ujs/blob/master/src/rails.js
  • place csrf_meta_tag helper above javascript_include_tags

hope helps!


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -