# Protect\_from\_forgery and page caching issue

**URL:** <https://www.ruby-forum.com/t/protect-from-forgery-and-page-caching-issue/143771>\
**Category:** Rails\
**Created:** [July 22, 2008, 5:02pm UTC](https://www.ruby-forum.com/t/protect-from-forgery-and-page-caching-issue/143771 "2008-07-22T17:02:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![de\_Villamil\_FrSSSSd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cc9497/32.png) [@de\_Villamil\_FrSSSSd](https://www.ruby-forum.com/u/de_Villamil_FrSSSSd)\
**Post date:** [July 22, 2008, 5:02pm UTC](https://www.ruby-forum.com/t/protect-from-forgery-and-page-caching-issue/143771/1 "2008-07-22T17:02:07Z")

</div>

Hello,

Using Rails 2.0.2, I have an issue with page caching and  
protect\_from\_forgery :

In application.rb, I have this  
protect\_from\_forgery :secret =\>  
‘1c8b953667056f1a3c324d6b369f6158’, :only =\> [:create, :edit, :update]

In my generated page, I have both

//

in the header, and

And still in application controller if !session session :session =\> new end

Unfortunately, I keep having error 500 everytime I try to post a  
comment. Here is the error dump :  
NoMethodError (undefined method `session_id' for {}:Hash): /vendor/ rails/actionpack/lib/action_controller/request_forgery_protection.rb: 126:in `authenticity\_token\_from\_session\_id’ /vendor/rails/actionpack/  
lib/action\_controller/request\_forgery\_protection.rb:108:in  
`form_authenticity_token' /vendor/rails/actionpack/lib/ action_controller/request_forgery_protection.rb:98:in `verified\_request?’ /vendor/rails/actionpack/lib/action\_controller/  
request\_forgery\_protection.rb:86:in `verify\_authenticity\_token’

## Any idea about what happens ? Regards, FrÃ©dÃ©ric

FrÃ©dÃ©ric de Villamil  
removed\_email\_address@domain.invalid tel: +33 (0)6 62 19 1337  
[http://fredericdevillamil.com](http://fredericdevillamil.com) Typo : [http://typosphere.org](http://typosphere.org)
