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

94 views
Skip to first unread message

Nirav

unread,
Oct 17, 2012, 7:14:47 AM10/17/12
to rubyonra...@googlegroups.com
hi 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

Colin Law

unread,
Oct 17, 2012, 7:23:39 AM10/17/12
to rubyonra...@googlegroups.com
On 17 October 2012 12:14, Nirav <nirav.m...@gmail.com> wrote:
> hi 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):

The important bit of this message is the bit about nil. You have
tried to call a method service_options on something that is nil.

>
> vendor/extensions/smartmove/app/controllers/quote_requests_controller.rb:136:in
> `load_regions'
> .....
> in
> "vendor/extensions/smartmove/app/controllers/quote_requests_controller.rb"
> line no:136 is
>
> @regions = ServiceDescription.find_by_name('region').service_options

So ServiceDescription.find_by_name('region') is nil, so probably there
is no record in the service_descriptions database with that name.

>
> 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

I guess that you are a beginner in Rails to be confused by this error.
I suggest you work through some tutorials on Rails in order to
understand the basic principles. A few days doing that will save you
a lot of time in the long run. railstutorial.org is good and is free
to use online. Make sure that you install the version of rails that
the tutorial expects.

Colin

Nirav

unread,
Oct 17, 2012, 9:14:49 AM10/17/12
to rubyonra...@googlegroups.com
Hi colin,

Thanx for reply

here is no data in service_descriptions table so i got your point but i am working on existing app but can't get service_options method in file of quote_request_controller.rb .  can you please give me some area to search in app. i searched in all included and require files. 

Thanking You,
Nirav   

Colin Law

unread,
Oct 17, 2012, 9:34:16 AM10/17/12
to rubyonra...@googlegroups.com
On 17 October 2012 14:14, Nirav <nirav.m...@gmail.com> wrote:
> Hi colin,
>
> Thanx for reply
>
> here is no data in service_descriptions table so i got your point but i am
> working on existing app but can't get service_options method in file of
> quote_request_controller.rb . can you please give me some area to search in
> app. i searched in all included and require files.

Sorry, I do not understand your question. If you are still referring
to your original problem it is not that service_options does not exist
but that the object you are trying to call it on is nil.

How are you getting on working through the tutorial I suggested?

Colin
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/5HXxyTYhEjEJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Nirav

unread,
Oct 17, 2012, 10:00:32 AM10/17/12
to rubyonra...@googlegroups.com, cla...@googlemail.com
Hi Colin,

Thanks for  reply,

I have gone through your post. but i add dummy data in my service_descriptions table but it will be error in it. App didn't get service_options so i can't locate service_options. i searched in controllers or helper methods which is related to quote_requested_controller.rb 

i am reading tutorial that suggested by you. but i have to solve it ASAP. so that's why i raise a query.

Thanking You,
Nirav 

Colin Law

unread,
Oct 17, 2012, 10:12:15 AM10/17/12
to rubyonra...@googlegroups.com
On 17 October 2012 15:00, Nirav <nirav.m...@gmail.com> wrote:
> Hi Colin,
>
> Thanks for reply,
>
> I have gone through your post. but i add dummy data in my
> service_descriptions table but it will be error in it. App didn't get
> service_options so i can't locate service_options. i searched in controllers
> or helper methods which is related to quote_requested_controller.rb
>
> i am reading tutorial that suggested by you. but i have to solve it ASAP. so
> that's why i raise a query.

Is there a service_options table?
If you look in model/service_description.rb do you see
has_many :service_options
If so then that means the two tables are related by a has_many
belongs_to relationship. See the Rails Guide on ActiveRecord
Associations for more details.

Really you have no way of getting it going without increasing your
basic knowledge level first. Take three days out and work right
through the tutorial then you will have a much better chance.

Colin

Nirav

unread,
Oct 17, 2012, 10:43:25 AM10/17/12
to rubyonra...@googlegroups.com, cla...@googlemail.com
Hi Colin,

Thanks for your valuable comment,

I really need more work on it. yes. there is a table service_options. 

in file that you have explained in previous comment 

class ServiceDescription < ActiveRecord::Base
  has_many :services, :through => :service_options
  has_many :service_options

  validates_presence_of :name
end

so that's i mailed to client to give full detail of his all database with data.

Thanks again colin for show me the right path

Thanking You
Nirav 
Reply all
Reply to author
Forward
0 new messages