We're sorry, but something went wrong(500)

Hi all,

Thankfully, my site is now live. It needs some tweaks, but most
importantly I need to fix the 500 internal server error I seem to be
getting.

We're sorry, but something went wrong(500), We've been notified about
this issue and we'll take a look at it shortly.

When I look at the log, it says:

NoMethodError (undefined method `find_by_user_id' for #<Class:
0xb5f1b188>):
  app/controllers/user_controller.rb:32:in `index'
  /usr/lib/ruby/1.8/phusion_passenger/rack/request_handler.rb:92:in
`process_request'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_request_handler.rb:
207:in `main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:
385:in `start_request_handler'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:
343:in `handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/utils.rb:184:in `safe_fork'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:
341:in `handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in
`__send__'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in
`main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in
`start_synchronously'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:163:in
`start'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:
209:in `start'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:262:in
`spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:
126:in `lookup_or_add'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:256:in
`spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:
80:in `synchronize'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:
79:in `synchronize'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:255:in
`spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:154:in
`spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:287:in
`handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in
`__send__'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in
`main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in
`start_synchronously'
  /usr/lib/phusion_passenger/passenger-spawn-server:61

So - the undefined method `find_by_user_id line in the user_controller
says:
@posts = Post.find_by_user.id( @user.id, 1, :limit => 1, :conditions
=> "active_post = 1", :order => "created_at desc")

THis worked perfectly fine in development, so I dont understand why it
hasn't rendered the page as it did in prod.

Has anyone else come across this issue before? If so - how/what do I
need to do to resolve it?

Many, many thanks (happy new year too!!) :slight_smile:

:slight_smile:

I'm going to go out on a limb & say that you did not perform your
migrations in the production environment. The find_by* methods are
dynamically generated. No find_by_user_id method => no user_id
column.

Yeah good spot.

I avoided rake db:migrate because of my error posted yesterday that
returned:
rake aborted!
undefined method `reenable' for <Rake::Task db:schema:dump =>
[environment]>:Rake::Task

So I understand your reply, but I don't know how to fix it... Is there
a solution besides manually adding in the additional columns myself?

I've not kept up with migrations, as we have to use a different method
here. You definitely want to fix your migrations, though.
Priorities, priorities...

If your table needs a user_id column then it is not surprising that it
does not work if you have not provided that column. I think you will
either have to fix the migration or add the column manually. If you
add it manually then when you get the migrations working you will have
further problems to work around as the db will be out of phase with
the migrations.

Colin

Thanks for that ,

I can add it manually, but as you say I'll always be out of sync. I'll
dig a bit deeper.

Thank you