Reputation: 12189
I'm developing some API for my mobile app, and I want to add some action to render CSRF token in JSON. I know that there is helper csrf_meta_tags for HTML views, but how can I do it in controller? Thanks in advance.
Upvotes: 4
Views: 6675
Reputation: 24340
You can use form_authenticity_token
in the controller. It uses session[:_csrf_token]
as suggested by @user123, and also initialize it if it has not been done yet (see source).
Upvotes: 3