Jump to content

The ultimate community for Ruby on Rails developers.


Photo

undefined method `description' for nil:NilClass


  • Please log in to reply
3 replies to this topic

#1 vanderleithome

vanderleithome

    Passenger

  • Members
  • 2 posts

Posted 10 May 2014 - 05:35 PM

Hello guys!

 

I'm new in this forum and new with Rails. 

 

I'm getting the error: undefined method `description' for nil:NilClass on this line:

 

<%= @realty.realty_type.description %>

 

Between, when I use the line bellow I got no erros, just the realty_type ID:

 

<%= @realty.realty_type %>

 

What I'm forgetting and why I can't get that property of the realty_type?

 

Thanks anyway.



#2 S0lll0s

S0lll0s

    Passenger

  • Members
  • 3 posts

Posted 11 May 2014 - 08:42 PM

The error means that @realty.realty_type is nil. Are you sure that <%= @realty.realty_type %> works at that exact spot?



#3 dailammoc

dailammoc

    Dispatcher

  • Members
  • 36 posts
  • Location/

Posted 13 May 2014 - 05:07 AM

Where did you declare 'description'?



#4 vanderleithome

vanderleithome

    Passenger

  • Members
  • 2 posts

Posted 14 May 2014 - 01:51 AM

The error means that @realty.realty_type is nil. Are you sure that <%= @realty.realty_type %> works at that exact spot?

 

Yes, it works fine! Just when I add the property of the class it returns an error.

 

 

Where did you declare 'description'?

 

That's just and property of that class, I don't know where it is declared.

 

 

Still waiting, thanks guys!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users