Welcome Guest | Login

rails flash just stopped working

I run a small production site on shared hosting with a single mongrel.  I also have a test server for the same site using fcgi on the same account.

Recently (can't say exactly when), I've started having a problem with the rails flash hash, but only on the test server.  I haven't made any source code changes that I can see that would have broke it.  The offending code is pretty simple.  In one action I prepare to view a form:

def new_profile
   @client = Person.find(params[:id])
   flash[:subjects]=[[@client.id,'self']]
....

after the form is submitted, I do some processing:

def create_profile
...
   flash[:subjects].each {|s|
...

On the production server (and the test server until recently as far as I know), this code works fine.  But now on only the test server, I get an error on the flash[:subjects].each line:

NoMethodError (undefined method `each' for nil:NilClass):
   /app/controllers/provider_controller.rb:249:in `create_profile'

and an Application Error returned to the browser.

I haven't froze rails gems, but both apps have this in the environment.rb:

RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION

I'm relatively 'light' on Rails deployment and linux in general, so perhaps there's something regarding sessions that I don't have set up right.  But I'm puzzled as to why it would suddenly break for no apparent reason.

Any help would be appreciated.

Thanks

2008-03-02 09:31 AM

Can you paste in the full error trace?  Is params[:id] getting posted correctly?  

2008-03-02 10:47 AM

Yes, I believe the params[:id] works, and that there is a Person with that id in the DB.  Here's more of the log:

Processing ProviderController#new_profile (for 68.246.254.209 at 2008-03-02 09:02:14) [GET]
 Session ID: 318318d683aada384cc8bfdc0e8c1879
 Parameters: {"action"=>"new_profile", "id"=>"26", "controller"=>"provider"}
Rendering  within layouts/provider
Rendering provider/new_profile
Completed in 0.00902 (110 reqs/sec) | Rendering: 0.00507 (56%) | DB: 0.00150 (16%) | 200 OK http://dev1.thecoreporation.com/provider/new_profile/26]


Processing ProviderController#create_profile (for 68.246.254.209 at 2008-03-02 09:02:19) [POST]
 Session ID: 318318d683aada384cc8bfdc0e8c1879
 Parameters: {"commit"=>"Create Profile", "profile"=>{"form_id"=>"2"}, "action"=>"create_profile", "controller"=>"provider"}


NoMethodError (undefined method `each' for nil:NilClass):
   /app/controllers/provider_controller.rb:256:in `create_profile'
   /app/controllers/provider_controller.rb:249:in `each'
   /app/controllers/provider_controller.rb:249:in `create_profile'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `send'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in `call_filter'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:638:in `call_filter'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:438:in `call'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:637:in `call_filter'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
   /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in `perform_action'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `send'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `process_without_filters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:168:in `process_request'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:143:in `process_each_request!'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:109:in `with_signal_handler'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:142:in `process_each_request!'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `each_cgi'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:141:in `process_each_request!'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:55:in `process!'
   /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:25:in `process!'
   dispatch.fcgi:24

2008-03-02 11:08 AM

OK--I'll have to own up to a stupid mistake on my part here.  It is not a flash/fcgi/whatever problem...  It turned out to be a glitch in the site DB that wasn't in any other install (and therefore I couldn't replicate and debug normally).  Mea culpa...

2008-03-03 12:38 PM

EDIT - ok I wrote this below while you posted the above. Glad its working now.

------------
Hmm - you're saying this all of a sudden stopped working? I know you said you can't remember exactly when, but anything you can remember about how your environment may have changed would be helpful.  What exactly is different from your production (which is working?) -- you sure that Person is there in the test database?

2008-03-03 12:41 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up.