Thanks a lot Mr. Fred. Now, I am having trouble with displaying the query result on authors\show.html I am having problems referencing the returned object and getting the two columns displayed. The error is: "You have a nil object when you didn't expect it!"
I have this in my model: 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| %> // I am not sure if this is right! <tr> <td><%=h @result.name %></td> <td><%=h @result.age %></td> </tr> </table> What I want to do is to display the 'name' and 'age' that the query returned. Please help! Cypray Frederick Cheung wrote: > On 4 Dec 2008, at 14:28, Jay Mark wrote: >> What I want to do is to display all author's name base on the selected >> age. >> >> please, What is wrong with my query? >> > because hashes are written with {} not () (and in fact you don't even > need the {} here) > > Fred -- Posted via http://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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---