script/console fails with custom_require.rb:31:in `gem_original_require'

Anyone have any ideas as to how I can find out what is causing this? Works fine on my dev box but not on my staging server. I suspect I have been using a gem on the dev box and not installed it on the staging box. I have failed to find the issue. How can I find out some more info on this. Backtrace below.

The controller (source at the bottom) that appears to be causing the problem has been generated using nifty_generators. Line 10. Suspicious?

Could anyone suggest something.



bison:/srv/www/vhosts/i4/staging/current # RAILS_ENV=staging script/ console Loading staging environment (Rails 2.3.4) /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': /srv/www/vhosts/i4/staging/releases/ 20091118113528/app/controllers/quote_refs_controller.rb:10: syntax error, unexpected kELSE, expecting ')' (SyntaxError)   from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'   from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:158:in `require'   from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:265:in `require_or_load'   from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:224:in `depend_on'   from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:136:in `require_dependency'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 414:in `load_application_classes'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 413:in `each'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 413:in `load_application_classes'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 411:in `each'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 411:in `load_application_classes'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 197:in `process'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 113:in `send'   from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb: 113:in `run'   from /srv/www/vhosts/i4/staging/releases/20091118113528/config/ environment.rb:13   from /usr/lib64/ruby/1.8/irb/init.rb:252:in `require'   from /usr/lib64/ruby/1.8/irb/init.rb:252:in `load_modules'   from /usr/lib64/ruby/1.8/irb/init.rb:250:in `each'   from /usr/lib64/ruby/1.8/irb/init.rb:250:in `load_modules'   from /usr/lib64/ruby/1.8/irb/init.rb:21:in `setup'   from /usr/lib64/ruby/1.8/irb.rb:54:in `start'   from /usr/bin/irb:13

--- app/controllers/quote_refs_controller.rb

class QuoteRefsController < ApplicationController   def new     @quote_ref =   end

  def create     @quote_ref =[:quote_ref])     if       redirect_to url_for(:controller => 'quote', :action => 'update', :id => @quote_ref.quote_id     else       render :controller => 'quote', :action => 'new'     end   end

  def show     @quote_ref = QuoteRef.find(params[:id])   end

  def update     @quote_ref = QuoteRef.find(params[:id])     if @quote_ref.update_attributes(params[:quote_ref])       flash[:notice] = "Successfully updated quote ref."       redirect_to @quote_ref     else       render :action => 'edit'     end   end end

The controller had the wrong name it should have been:

class PromotionController < ApplicationController

That is invalid syntax - you never close the ( that you opened after url_for. The reason you get this in staging but not in development is presumably that your staging environment is similar to production, ie rails is set to preload all your source at load time, whereas in development that file would not be loaded (and thus the syntax error not reported) until it needed to be.



Thank you for your reply. I did discover the same thing..... finally. What I did was set up a temporary staging environment on my development box and sure enough I got the same error. Then on much closer inspection I saw the same thing. The clue was in the message!

20091118113528/app/controllers/quote_refs_controller.rb:10: syntax error, unexpected kELSE, expecting ')' (SyntaxError)

The thing that threw me was that I hadn't really appreciated the pre- load of source at load time (which explains the delay when restarting the webserver).

Hopefully this thread will help someone in the future.