i am using rails 2.3.4 and i am facing "no method error"
there is possibility to not find method but my question is - is there possibility to error occurred because of empty table? or error in another controller or helper?
error trace:
Processing QuoteRequestsController#create (for 127.0.0.1 at 2012-10-17 16:07:34) [POST] Parameters: {"controller"=>"quote_requests", "quote_request"=>{"packing_required"=>"", "move_steps_number"=>"", "phone_day"=>"", "pickup_region_id"=>"", "email"=>"", "move_to_street"=>"", "move_from_suburb"=>"", "title"=>"", "quick_estimate"=>"true", "room_counts"=>{"9"=>"0", "8"=>"0", "5"=>"0", "2"=>"0", "3"=>"0", "6"=>"0", "7"=>"0", "1"=>"0", "4"=>"", "11"=>"0"}, "arrive_parking_notes"=>"", "first_name"=>"", "arrive_date_flexible"=>"false", "insurance_value"=>"", "arrive_steps_number"=>"", "move_parking_notes"=>"", "last_name"=>"", "move_region_id"=>"", "move_date_flexible"=>"false", "move_type_id"=>"26", "move_to_city"=>"", "arrive_date"=>"", "move_from_street"=>"", "move_date"=>"", "move_to_suburb"=>"", "move_from_city"=>"", "phone_mobile"=>""}, "authenticity_token"=>"U42qF1c0FJXvnC1SCNNYWzxKN3Pem7dC6L01LbTQD7E=", "commit"=>"Submit", "action"=>"create"}
NoMethodError (undefined method service_options' for nil:NilClass):
vendor/extensions/smartmove/app/controllers/quote_requests_controller.rb:136:in
load_regions'
vendor/radiant/vendor/plugins/haml/rails/./lib/sass/plugin/rails.rb:19:in `process'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:162:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:95:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:92:in `each'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:92:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:23:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:82:in `start'
in "vendor/extensions/smartmove/app/controllers/quote_requests_controller.rb" line no:136 is
@regions = ServiceDescription.find_by_name('region').service_options
in my database table is there service_descriptions and service_options. is there related to mysql or controller? please guide me i am very much confuse. this is existing application i have to configure in local as well as on server
Thank you in advance
Thanking You Nirav
You are getting error because
ServiceDescription.find_by_name('region')
returnsnil
(This simply means you have no data in yourservice_descriptions
table with name'region'
) and then you are callingservice_options
on it (i.e.nil
)Best way to avoid such case is to check if value is nil or not before applying any method it.