开发者

Rails form_tag spanning partial and ActionController::InvalidAuthenticityToken

Using a :partial for the start of a "form_tag" and the "end" in a different :partial gave

"compile error" and "syntax err开发者_C百科or, unexpected kENSURE, expecting kEND".

Changing the "form_tag" to a standard HTML "form" tag fixes that but gives "ActionController::InvalidAuthenticityToken".


Adding

<%= token_tag %> 

just after the HTML form tag fixes issue.


This is because form_tag is a block and the end must be contained in the same file. For example, the following code is impossible:

foo.rb

 def some_method
   puts "test"
 require 'end'

end.rb

 end

This is due the order in which the code is evaluated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜