I was having problem with rails plugin auto_complete.
The problem is that when you use protect_from_forgery then auto_complete gives error.
Rails version: Rails 2.0.2
This I have in controller:
auto_complete_for :userEquipment, :name
This I have in view:
text_field_with_auto_complete :userEquipment, :name
But I was having such error:
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
The answer is here in file auto_complete_macros_helper.rb
You need to change this line:
auto_complete_field("#{object}_#{method}", { :url => { :action => "auto_complete_for_#{object}_#{method}" } }.update(completion_options))
To this line:
auto_complete_field("#{object}_#{method}", { :url => { :action => "auto_complete_for_#{object}_#{method}", :authenticity_token => "#{form_authenticity_token}" } }.update(completion_options))
And now it's working!
But I'm new in Rails, so maybe there is nicer way. :)
svētdiena, 2008. gada 17. februāris
sestdiena, 2008. gada 16. februāris
What is this blog about?
I'm now learning to make web application in rails and in learning process I'm having many small things that are not clearly described in internet. So, here I will share with these things.
Abonēt:
Ziņas (Atom)