My code was running fine under Rails 2.0.2. Then I enabled the db based session store by uncommenting this:
config.action_controller.session_store = :active_record_store
in environment.rb.
Anything that used the session after that gave me this error:
No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).
If you have the same problem. Go to application.rb and uncomment the secret then restart.
All better.
Tags: protect_from_forgery · Ruby On Rails · sessions46 Comments












46 responses so far ↓
I listened – thanks
well – it’s not entirely true, you know!
I mean – somebody actually listens!
Thanks for sharing!
Ever come to Denmark? Give me a call – and I’ll try to make up for the tip
/Walther
wow thank you soo much, I was following along a rails tutorial when I ran into that very problem and had no clue, you’re info is much apreciated
Helpful sharing.
I didn’t enable the db based session store but also encountered the same problem, and solved it per your guidance.
Thanks.
Thanks for your help for this one. Solved my bug…
Thanks very much. I had the same problem & I had no idea what was going wrong
thanks a lot!!! that saved me a lot of trouble!
Thank you very much for this tip! Very helpful!
Yes thanks for that tip, but could somebody explain why (is that for recognizing sessions on every pages and we just avoid the problem by uncommenting the secret or ??)???
Could somebody explain the issue ??
thanks! I’m going through the latest beta of pragprog Agile Rails 3rd ed and ran right into this bug.
Ah, thanks!
Thanks
Hey, thanks a lot, you saved at least hour or may be more of my time.
There are people who share their knowledge and you are one of then
Thanks
Many thanks – it helps me a lot
)
Lo
Thanks! Saved me some time to figure it out.. =)
Thanks it was handy…
You rock! This is great!
Thanks, I was looking at how to fix it!
Thanks a lot! And … by the way so many people listening to you
Looks like I’m definitely not the only one who can say this, but thanks much man! I had no idea where to begin (other than to google the error, which brought me here
)
Good catch for the error above. I got the same problem but now I know how to fix it.
Thanks
Thanks man. I would have never figured that out on my own.
Thanks for the help
thanks justin.
thomas, no this isn’t a hack we may regret in the future. the error message tells us to do exactly this, just doesnt say where. in app.rb, the comment confirms that its ok to do so in this situation.
Thanks man… You were very helpful!
Best regards from Romania!
I to had the same problem and this was the perfect fix.
Thank you!!!!
THANKS A LOT!!!!!
Thanks! The fact that there is a secret in config/environment.rb makes this extremely not obvious how to fix. Your post saved the day.
I am still getting that error Even after uncommenting that line.
Here’s what i am trying to do..
i tried to add that line of code in rhtml file
:add_to_cart, :id=> product %>
Any help would be greatly appericiated.
Thank you. Really appreciate.
Thanks
Thank you so much!
Thank you, sir! very helpful
Thank you very much fot this tip. It was very helpful
you saved whole Polish nation those info.
thank you so much.
Thanks for the information. It was really helpful. Appreciable attempt!!!
Much obliged.
Thank you very much!
Thanks!
me as a nobody listened, many thanks
eh… luv it )
Thanks a lot dude……….
Thanks You Very Much !!!!
Thank you!!!!
Thanks for your great information…