Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

rails_admin throw ActionController::InvalidAuthenticityToken in rails-api #2919

Closed
buncis opened this issue Aug 28, 2017 · 5 comments
Closed

Comments

@buncis
Copy link
Contributor

buncis commented Aug 28, 2017

rails_admin throw ActionController::InvalidAuthenticityToken when I want to create model

image

rails version 5.1.2 with --api mode
rails_admin version 1.2.0

change config.api_only from true to false in application.rb fix the problem idk why, anyone care to explain?

buncis added a commit to buncis10/lazy-api that referenced this issue Aug 28, 2017
railsadminteam/rails_admin#2919
dirubah di application.rb dari api_only true jadi false
@buncis
Copy link
Contributor Author

buncis commented Sep 9, 2017

I think its related with this #2830
adding these stack into rails middleware also fix this

# application.rb
config.session_store :cookie_store
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
config.middleware.use Rack::MethodOverride

#2830 (comment)
#2739 (comment)

@efrapp
Copy link

efrapp commented Feb 6, 2018

Thanks @buncismamen it worked for me!!

@visheshruparelia
Copy link

Thank you, this fixed it. But I don't get why this worked, can you explain? @buncismamen

@buncis
Copy link
Contributor Author

buncis commented Mar 21, 2018

@visheshruparelia because rails-api remove some middleware stacks that rails admin needs.
so you just need to re-added it.

robbywashere-zz pushed a commit to robbywashere-zz/rails_admin that referenced this issue Mar 25, 2018
robbywashere-zz pushed a commit to robbywashere-zz/rails_admin that referenced this issue Mar 25, 2018
Add missing cookie middleware when rails is used in api mode
mshibuya added a commit that referenced this issue Jul 16, 2018
@mshibuya
Copy link
Member

Fixed by #3006.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants