Hello,
I have this problem that my rails application works fine in development
environment on my local Linux and windows system but when I uploaded it
to work on the server in production environment I have this problem as
listed in the pasted log file at the end of this entry:
NoMethodError (undefined method []' for nil:NilClass): /app/controllers/admin_controller.rb:201:in
update’
the support team could not crack this one. I would think that the method
“update_attributes” would just work. if I enter a new entry to the data
base “mysql” it works fine and also the sort works fine in updating the
data base.
I have attached the controller file. all the functions work except for
the update one and only when it is running on the hosting server under
production environment.
I do not understand why it says in the log file nilclass when the return
@params is not nil.
Hope someone can help me on this one.
********* controller *******************
def update
if session[:project_cat].nil? then
redirect_to :action => ‘index’
else
@category = Parent.find_by_cat_name(session[:project_cat])
if @category.cat_name == “branding” then
@project = @category.brandings.find(params[:id])
elsif @category.cat_name == “client_say” then
@project = @category.client_says.find(params[:id])
else
@project = @category.projects.find(params[:id])
end
if @project.update_attributes(@params[:project]) # this is line 201
flash[:notice] = ‘Project was successfully updated.’
redirect_to :action => ‘show’, :id => @project, :cat_name =>
@category.id
else
render :action => ‘edit’, :cat_name => @category.id
end
end
end
***** log file *************************
Processing AdminController#update (for 81.3.100.245 at 2008-02-07
05:22:08) [POST]
Session ID:
BAh7CjoWcHJvamVjdF9pbWFnZV91cmx7ADoQcHJvamVjdF9jYXQiCW1pc2M6%0ACXVzZXJpBzoOcmV0dXJuX3RvMCIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxl%0Acjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA%3D%3D–be44b352117c1f931fe6eb0eab2a7f0b99ab8edd
Parameters: {“commit”=>“Save”, “cat_name”=>“3”,
“project”=>{“tags”=>“flash private”, “client”=>“Mom & Dad”,
“description”=>“A movie clip for my parent’s 35 anniversary”,
“url_link”=>""}, “action”=>“update”, “id”=>“25”, “controller”=>“admin”}
NoMethodError (undefined method []' for nil:NilClass): /app/controllers/admin_controller.rb:201:in
update’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in
send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in
perform_action_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in
call_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in
perform_action_without_benchmark’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68: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-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in
perform_action_without_caching’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in
perform_action' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
cache’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in
cache' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in
perform_action’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
process_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in
process_without_session_management_support' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in
process’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in
process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in
handle_request’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in
dispatch' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in
dispatch_cgi’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in
dispatch' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel/rails.rb:76:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel/rails.rb:74:in
synchronize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel/rails.rb:74:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel.rb:159:in
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel.rb:158:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel.rb:158:in
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel.rb:285:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel.rb:285:in
initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel.rb:285:in
new’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel.rb:285:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel.rb:268:in
initialize’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel.rb:268:in
new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel.rb:268:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel/configurator.rb:282:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel/configurator.rb:281:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel/configurator.rb:281:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/mongrel_rails:128:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel/command.rb:212:in
`run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.3/bin/mongrel_rails:281
Rendering /home/saydigi/saydigitaldesign/public/500.html (500 Internal
Server Error)