kurenn / sabisu-rails

Simple and powerful engine for exploring your Rails api application
MIT License
127 stars 29 forks source link

undefined method `layout' for SabisuRails::BaseController:Class #36

Closed camkidman closed 8 years ago

camkidman commented 8 years ago

Trying to use sabisu-rails for my API that I'm building and, upon following the readme, the very first thing I'm presented with is undefined method 'layout' for SabisuRails::BaseController:Class

Gemfile

initializers/sabisu-rails.rb

Full stack trace:

    /Users/sp33k3rph433k/.rvm/gems/ruby-2.2.1/bundler/gems/sabisu-rails-af7499e87912/app/controllers/sabisu_rails/base_controller.rb:4:in `<class:BaseController>'
    /Users/sp33k3rph433k/.rvm/gems/ruby-2.2.1/bundler/gems/sabisu-rails-af7499e87912/app/controllers/sabisu_rails/base_controller.rb:2:in `<module:SabisuRails>'
    /Users/sp33k3rph433k/.rvm/gems/ruby-2.2.1/bundler/gems/sabisu-rails-af7499e87912/app/controllers/sabisu_rails/base_controller.rb:1:in `<top (required)>'
    activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `load'
    activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
    activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
    activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
    activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
    activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
    activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
    /Users/sp33k3rph433k/.rvm/gems/ruby-2.2.1/bundler/gems/sabisu-rails-af7499e87912/app/controllers/sabisu_rails/explorer_controller.rb:2:in `<module:SabisuRails>'
    /Users/sp33k3rph433k/.rvm/gems/ruby-2.2.1/bundler/gems/sabisu-rails-af7499e87912/app/controllers/sabisu_rails/explorer_controller.rb:1:in `<top (required)>'
    activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `load'
    activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
    activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
    activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
    activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
    activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
    activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
    activesupport (4.2.0) lib/active_support/inflector/methods.rb:263:in `const_get'
    activesupport (4.2.0) lib/active_support/inflector/methods.rb:263:in `block in constantize'
    activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `each'
    activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `inject'
    activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `constantize'
    activesupport (4.2.0) lib/active_support/dependencies.rb:566:in `get'
    activesupport (4.2.0) lib/active_support/dependencies.rb:597:in `constantize'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:59:in `controller'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:38:in `serve'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
    railties (4.2.0) lib/rails/engine.rb:518:in `call'
    railties (4.2.0) lib/rails/railtie.rb:194:in `public_send'
    railties (4.2.0) lib/rails/railtie.rb:194:in `method_missing'
    actionpack (4.2.0) lib/action_dispatch/routing/mapper.rb:51:in `serve'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
    warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
    warden (1.2.3) lib/warden/manager.rb:34:in `catch'
    warden (1.2.3) lib/warden/manager.rb:34:in `call'
    rack (1.6.4) lib/rack/etag.rb:24:in `call'
    rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
    rack (1.6.4) lib/rack/head.rb:13:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
    activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
    activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
    activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
    activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
    activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
    activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
    activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
    actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
    railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
    railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
    activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
    activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
    activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
    railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
    rack (1.6.4) lib/rack/runtime.rb:18:in `call'
    activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
    rack (1.6.4) lib/rack/lock.rb:17:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
    railties (4.2.0) lib/rails/engine.rb:518:in `call'
    railties (4.2.0) lib/rails/application.rb:164:in `call'
    rack (1.6.4) lib/rack/content_length.rb:15:in `call'
    puma (2.14.0) lib/puma/server.rb:541:in `handle_request'
    puma (2.14.0) lib/puma/server.rb:388:in `process_client'
    puma (2.14.0) lib/puma/server.rb:270:in `block in run'
    puma (2.14.0) lib/puma/thread_pool.rb:106:in `call'
    puma (2.14.0) lib/puma/thread_pool.rb:106:in `block in spawn_thread'
kurenn commented 8 years ago

I could not reproduce, this is my Gemfile, the only difference basically is I'm using version 1.5 from furatto and removed the compass-rails dependency as is already included in the furatto newest version:

source "https://rubygems.org"

ruby "2.2.3"

gem "versionist"
gem "active_model_serializers", github: "rails-api/active_model_serializers", branch: "0-8-stable"
gem 'sabisu_rails', github: "IcaliaLabs/sabisu-rails"
gem 'furatto', "~> 1.5"
gem 'font-awesome-rails'
gem 'simple_form'

gem "rails", "4.2.1"
gem "jquery-rails"
gem "pg"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.1.0"
gem "uglifier", ">= 1.3.0"
gem "puma"

group :development do
  gem "spring"
  gem "spring-commands-rspec"
  gem "web-console"
end

group :development, :test do
  gem "awesome_print"
  gem "factory_girl_rails"
  gem "pry-rails"
  gem "rspec-rails", "~> 3.1.0"
  gem "ffaker"
end

# Test gems
group :test do
  gem "database_cleaner"
  gem "shoulda-matchers"
end

# Production and staging gems
group :production, :staging do
  gem "rails_12factor"
  gem "exception_notification"
end
lesreaper commented 8 years ago

I'm having this same issue. I also tried matching your gemfile, with a bundle update, and didn't work. I sent you a tweet with image of error.

kurenn commented 8 years ago

If you are following the api's on rails tutorial, you can skip the sabisu integration with no problem! just so you don't stop learning, I'll take a look at this in the meantime

jakehockey10 commented 8 years ago

the gem rails-api is not including ActionView::Layout in the ActionController::API. @kurenn , it looks like another difference between your Gemfile and @camkidman 's is that they are using the rails-api gem. I'm having the same issue and if I include ActionView::Layout inside of the BaseController of this gem, then I seem to be getting rid of the this specific error. Now I'm getting a page that tells me I need to log in first.

kurenn commented 8 years ago

@jakehockey10 for the admin section you can access with the following credentials:

username: admin
password: sekret
jakehockey10 commented 8 years ago

Thanks :-)

camkidman commented 8 years ago

Seems like that's the fix for it @jakehockey10 -- Maybe explicitly making ActionView::Layout a dependency for this gem would clear up some of the confusion for those using rails-api? I'm not sure if it's relevant pending the inclusion of rails-api into Rails 5, though

lesreaper commented 8 years ago

I just gave up and started using Postman. Sorry. :(

Sent from my iPhone

On Dec 17, 2015, at 3:16 PM, Cameron Kidman notifications@github.com<mailto:notifications@github.com> wrote:

Seems like that's the fix for it @jakehockey10https://github.com/jakehockey10 -- Maybe explicitly making ActionView::Layout a dependency for this gem would clear up some of the confusion for those using rails-api? I'm not sure if it's relevant pending the inclusion of rails-api into Rails 5, thoughhttps://github.com/rails/rails/pull/19832

— Reply to this email directly or view it on GitHubhttps://github.com/IcaliaLabs/sabisu-rails/issues/36#issuecomment-165570848.

theterminalguy commented 8 years ago

add this to your application controller include ActionView::Layouts

camkidman commented 8 years ago

There's a workaround for this issue, closing.