Nil object problem in Rails 2.0.2

I think my problem is that Rails is not seeing the private method “def
author_age” that is holding the result of the query.
Do I suppose to put this in the Controller and not in the model?
How does the object @results get known to Rails?

Here is my code:

class Author < ActiveRecord::Base

has_many :books

def author_age
@results = Author.find :all, :conditions => [“age = ?”,
params[:authors]]
end
end

I have this on view\authors\show.html

<% @results.each do |result| %>

<% end %>

Author Name

Age

<%=h result.name %> <%=h result.age %>

Cypray

On Dec 6, 3:03 pm, Jay M. [email protected] wrote:

I think my problem is that Rails is not seeing the private method “def
author_age” that is holding the result of the query.

It’s not a private method.

Do I suppose to put this in the Controller and not in the model?
How does the object @results get known to Rails?

You’re only showing a portion of your code, but the view sees instance
variables of the corresponding controller, not of models.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs