Ruby on Rails Unprocessable Entity Error
2009-11-10 11:03:31 | 0 Comment
While I was trying to complete a Ruby on Rails project of mine, I had this error came up. Probably other developers will face it too. And you probably didn't create your form with form_for helper but instead you have written it yourself. Don't worry that's not bad. Rails is slow itself, stop making it slower by using the helpers. Here is the solution:
Don't forget to add "authenticity_token" as a hidden input to your form. With form_for helper, it adds this input automatically but we forget to include it in our form. So all you should do is:
How you will get @token local variable? In your controller, you should have this line:
@token = session[:_csrf_token]
You are just fine after this.
Check my latest project compector.com where you can post references about your former employers and see what others have said about the future employers. Sign up now and post a reference and share it on twitter or facebook.


Comments
Leave a Response