On Dec 6, 3:03 pm, Jay Mark
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
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>
> 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
>
> <table border="1">
> <tr>
> <td width="20%"><p
align="center"><i><b>Author
Name</b></i></td>
> <td width="20%"><p
align="center"><i><b>Age</b></i></td>
> </tr>
>
> <% @results.each do |result| %>
>
> <tr>
>
> <td><%=h result.name %></td>
> <td><%=h result.age %></td>
> </tr>
> <% end %>
> </table>
>
> Cypray
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---