NoMethodError (undefined method `call' for nil:NilClass):

I am getting HTTP 500 Internal server error when updating info for one
of page of my website. Please help me and for your reference i have
posted ruby trace below:

Processing ModelsController#update (for 203.187.233.94 at 2009-03-20
02:40:06) [PUT]
Session ID:
BAh7CDoMY3NyZl9pZCIlYTc0NDc5OWI1ZDNhMDM4YmVjZTY0YjE3NGZkODQ2
YjAiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh
c2h7AAY6CkB1c2VkewA6DHVzZXJfaWRpBw==–0cc7b78313f817b2be3cc19a19164dbfa9a351e9
Parameters: {“commit”=>“Update”, “action”=>“update”,
“_method”=>“put”,
“authenticity_token”=>“47bc4f13abf32c82e7602e1ebd52f5a5338a566d”,
“id”=>“12”, “controller”=>“admin/models”, “model”=>{“city”=>“Surat”,
“biography”=>"", “measurements”=>"", “weight”=>“110”,
“agency_rep_email”=>"", “agency_address”=>"", “country_id”=>“1”,
“approved”=>“0”, “agency_name”=>"", “region_id”=>“1”, “sex”=>“m”,
“agency_rep_name”=>"", “height”=>“5’3”, “first_name”=>“Jignesh”,
“agency_phone”=>"", “eye_color_id”=>“3”, “hair_color_id”=>“9”,
“age”=>“30”, “last_name”=>“Wadia”}}

NoMethodError (undefined method call' for nil:NilClass): /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/mime_responds.rb:156:inrespond’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/mime_responds.rb:154:in each' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/mime_responds.rb:154:inrespond’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/mime_responds.rb:107:in respond_to' /app/controllers/admin/models_controller.rb:64:inupdate’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:1162:in send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:1162:inperform_action_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/filters.rb:580:in call_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/filters.rb:573:inperform_action_without_benchmark’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/benchmarking.rb:68:in
perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:inmeasure’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/benchmarking.rb:68:in
perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/rescue.rb:201:inperform_action_without_caching’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/caching/sql_cache.rb:13:in perform_action' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active_record/connection_adapters/abstract/query_cache.rb:33:incache’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/query_cache.rb:8:in cache' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/caching/sql_cache.rb:12:inperform_action’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:529:in send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:529:inprocess_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/filters.rb:569:in
process_without_session_management_support' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/session_management.rb:130:inprocess’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:389:in process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:149:inhandle_request’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:107:in dispatch' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:104:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:104:in dispatch' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:120:indispatch_cgi’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:35:in dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 103:inprocess_request’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
153:in with_signal_handler' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 101:inprocess_request’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
78:in process_each_request' /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:ineach_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:ineach_cgi’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
77:in process_each_request' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 76:incatch’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
76:in process_each_request' /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb: 50:inprocess!’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:
24:in `process!’
dispatch.fcgi:24

Rendering /home/canadian/canadianmodelscouts.com/public/500.html (500
Internal Server Error)

REgs,
Jignesh W.

it would be a good idea to post the controller method update and the
class Model.

“Wolas!” wrote:

it would be a good idea to post the controller method update and the
class Model.

But how can I fix that error message? Database information is updating
properly but page is redirecting to HTTP 500 Internal server error page
and I am unable to fix this error. Please help me how can i fix it. I am
using code below to be updating model entry… and same code works
properly for other modules.

PUT /models/1

PUT /models/1.xml

def update
@model = Model.find(params[:id], :include=>:user)

respond_to do |format|
  if @model.update_attributes(params[:model])
    @model.user.roles.clear

@model.user.roles << Role.find_or_create_by_name(“model”)
#flash[:notice] = “Model was successfully updated.”
#format.html { redirect_to([:admin, @model]) }
#format.xml { head :ok }
else
format.html { render :action => “edit” }
format.xml { render :xml => @model.errors, :status =>
:unprocessable_entity }
end
end
end

On Mar 20, 12:00 pm, Jignesh W. [email protected]
wrote:

respond_to do |format|
  if @model.update_attributes(params[:model])
    @model.user.roles.clear

@model.user.roles << Role.find_or_create_by_name(“model”)
#flash[:notice] = “Model was successfully updated.”
#format.html { redirect_to([:admin, @model]) }
#format.xml { head :ok }

in this branch you’re not telling rails what to do - you’ve commented
out all your format.bla calls

Fred

When running database queries from form input, I usually change params
[foo][id] to an integer. Everything passed with the request object is
of type “string” and will return a nil object in Ruby.

Model.find(params[foo][id].to_i)

On Mar 21, 2:00 am, Jignesh W. [email protected]

Frederick C. wrote:

On Mar 20, 12:00�pm, Jignesh W. [email protected]
wrote:

� � respond_to do |format|
� � � if @model.update_attributes(params[:model])
� � � � @model.user.roles.clear
� @model.user.roles << Role.find_or_create_by_name(“model”)
� � � � #flash[:notice] = “Model was successfully updated.”
� � � � #format.html { redirect_to([:admin, @model]) }
� � � � #format.xml �{ head :ok }

in this branch you’re not telling rails what to do - you’ve commented
out all your format.bla calls

Fred

Okay now I have activated commented statements but still I am getting
same error message ane redirecting to 505 error page.

Jignesh W.