Well, I am having trouble with this query:
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>
</table>
I am getting this error: "You have a nil object when you didn't
expect it!"
The log shows "NULL" for the selected age whose value should be passed
in as the condition for the query.
So, I wanted to change the primary key just to see if it might make any
difference. I don't know what is wrong with the query.
In SQL, the query is like this:
SELECT name, age FROM author WHERE age = "the user selected age"
Cypray.
Bobnation wrote:
> First thing I would ask is "why?" What is the reason behind the
> change?
--
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---