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.
2 Answers
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).