Md Sirajus Salayhin
Md Sirajus Salayhin

Reputation: 5144

Active admin error on Rails 4.0.2 application

Got this error while installing active admin on rails 4.0.2 application. I am using rails-api, where I need something like this admin to manage content apart from client.

undefined method `layout' for ActiveAdmin::Devise::SessionsController:Class

I am not sure about this error.

Upvotes: 0

Views: 1581

Answers (3)

Fangxing
Fangxing

Reputation: 6135

When use rails-api(it's merged into rails 5 now), your ApplicationController will inherits from ActionController::API instead of ActionController::Base, while rails admin dependents on ActionController::Base and some other middlewares. To make active admin works with rails api mode, your need to do some additional work:

  1. Make your ApplicationController inherit from ActionController::Base

    class ApplicationController < ActionController::Base
    
  2. Modify your config/application.rb like this

    class Application < Rails::Application
      # ...
      config.middleware.use ActionDispatch::Flash
      config.middleware.use Rack::MethodOverride
      config.middleware.use ActionDispatch::Cookies
    end
    

References:
1. https://rrott.com/blog/ror/rails-5-api-with-activeadmin-integration.html
2. What is the difference between a regular Rails app and a Rails API?

Upvotes: 1

l_gerard
l_gerard

Reputation: 73

It is now ActionView::Layouts

See https://github.com/rails/rails/issues/14517

Upvotes: 2

Md Sirajus Salayhin
Md Sirajus Salayhin

Reputation: 5144

Okay looks like it has been solved by adding this on application controller.

include AbstractController::Layouts

Upvotes: 2

Related Questions