Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTessa Davis
4,152 PointsHeroku deploy problem - tearing my hair out
I have a lovely app that works perfectly on my localhost but I can't deploy it on heroku. I have spent several days trying to resolve this and have no clue what else to try. I renamed my controller/admin/user_controller.rb to UserController rather than UsersController to avoid any conflict but it's still listing UsersController in the errors log. PLEASE HELP. If you solve this I will give you a virtual hug.
heroku run rake gives me this:
Running `rake` attached to terminal... up, run.7569
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.
Called from: /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.
Rack::File headers parameter replaces cache_control after Rack 1.5.
/app/app/controllers/admin/users_controller.rb:1:in `<top (required)>': superclass mismatch for class UsersController (TypeError)
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:359:in `require_or_load'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:313:in `depend_on'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:225:in `require_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:438:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:438:in `block in eager_load!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:436:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:436:in `eager_load!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `instance_exec'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `run'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `run_initializers'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:136:in `initialize!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /app/config/environment.rb:5:in `<top (required)>'
from /app/test/test_helper.rb:2:in `require'
from /app/test/test_helper.rb:2:in `<top (required)>'
from /app/test/functional/admin/user_controller_test.rb:1:in `require'
from /app/test/functional/admin/user_controller_test.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:10:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `select'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `<main>'
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.
Called from: /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.
Rack::File headers parameter replaces cache_control after Rack 1.5.
/app/app/controllers/admin/users_controller.rb:1:in `<top (required)>': superclass mismatch for class UsersController (TypeError)
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:359:in `require_or_load'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:313:in `depend_on'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:225:in `require_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:438:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:438:in `block in eager_load!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:436:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/engine.rb:436:in `eager_load!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `instance_exec'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `run'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `run_initializers'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:136:in `initialize!'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /app/config/environment.rb:5:in `<top (required)>'
from /app/test/test_helper.rb:2:in `require'
from /app/test/test_helper.rb:2:in `<top (required)>'
from /app/test/integration/custom_routes_test.rb:1:in `require'
from /app/test/integration/custom_routes_test.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:10:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `select'
from /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb:4:in `<main>'
Errors running test:units! #<NoMethodError: undefined method `[]' for nil:NilClass>
Errors running test:functionals! #<RuntimeError: Command failed with status (1): [ruby -I"lib:test" -I"/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib" "/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb" "test/functional/**/*_test.rb" ]>
Errors running test:integration! #<RuntimeError: Command failed with status (1): [ruby -I"lib:test" -I"/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib" "/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/rake_test_loader.rb" "test/integration/**/*_test.rb" ]>
7 Answers
finlay
2,983 PointsI was having an issue last night but wasn't seeing the whole stack trace so was struggling to debug the issues.
Running 'heroku logs -n 1500' should return more of the trace and help you identify the problem.
Jim Hoskins
Treehouse Guest TeacherOk, so I'm going to swing at this, but it's hard to say for sure without your code in front of me. A link to your github repo would be great if you have it. This is my theory, could be entirely wrong.
Googling superclass mismatch for class
it seems it's an error when you are re-opening a class in ruby but the superclass your are inheriting from doesn't match what's already there. In ruby you can define a class, and later, using the same class syntax "open" it again to add methods. If both times you open it it defines different parent classes like ApplicationController vs AdminController, that's a problem.
So why is this happening? Since you have this controller in controllers/admin not just controllers it's indicating you want all of those controllers in /admin to be part of some admin module or namespace. Also, I assume you also have controllers/users_controller.rb, which is the "non-admin" controller of users.
When you put controllers in a module like admin, it actually expects the class defined inside to be defined as a class contained in a module. Basically in controllers/admin/users_controller.rb, it would expect class Admin::UsersController < ...
instead of class UsersController < ...
. These are two distinct classes, so your solution of UsersController vs UserController correctly recognizes the problem, it's just not quite the best, "rails-y" solution.
So, why does it work on your machine, and not on heroku? Environments. When you develop, you are in the "development" environment. When you launch you are in "production". One obvious difference is development gives you stack traces on the web page, while production gives you an "Oops something went wrong" page, but there are other differences.
In development, code is selectively loaded and reloaded as you go, that's how changes in your code can be seen immediately, without restarting rails. That's inefficient for production, and unneeded, so in production all your code is loaded upfront. So in development, your two controllers are not triggering an error because only one is loaded at a time, and it's not "reopening" the class. But if the code loads both controllers, like in production, bang! Error.
Namespaced controllers are a little tricky to get used to, and I still occasionally get bit by them. For the life of me I can't find good documentation on it, I'll ask Jason and our other rails devs if there's a good resource for explaining this.
Tessa Davis
4,152 PointsThanks for the replies. Jim your explanation actually makes sense to me - not to say I have solved the problem but my heart rate is calming.
I'm pretty sure I only added the namespace controller following my google searching on how to solve this problem. The class is actually class Admin::UserController. I don't seem to have controllers/user_controller.rb
My repository is here https://github.com/tessadavis/guidelines
So I guess I need to try to work out where the conflict is?
Tessa Davis
4,152 Points.
Tessa Davis
4,152 PointsJust wondering if anyone could take pity on me to look at my code as I am still unable to work out how to deploy this...
Jim Hoskins
Treehouse Guest TeacherIs it still the same error? Try removing your recent code, and adding it back until you pinpoint exactly where the error is coming from.
Tessa Davis
4,152 PointsYes, it's the same error. I am rather confused about removing recent code. I have done git checkout to see old versions but it is basically taking me back to pretty early on to find a version without and error - so am close to starting from scratch. To avoid this problem next time am I supposed to deploy to heroku every time I do a git push? I can't see how else I could have picked up this problem.