I setup a method in my model to get a rank (it does an avg) and i get
this error when i view the page. what im thinking is even though i use
the as sysrank AR doesnt let me reference it? if not how would i do
this?
thanks
Sam
undefined method `sysrank'' for #<Array:0x25890d4>
Extracted source (around line #27):
24: <% if @myrank = Comment.rank(@system.id) %>
25: <tr>
26: <td>
27: RANK: 1 - 10 <%= @myrank.sysrank %>
28: </td>
29: </tr>
30: <% end %>
model:
class Comment < ActiveRecord::Base
belongs_to :systems
def self.rank(id)
find_by_sql (["SELECT system_id, avg(rank) as sysrank from
comments where system_id=? group by system_id",id])
end
end
Here is the view snippet:
<% if @myrank = Comment.rank(@system.id) %>
<tr>
<td>
RANK: 1 - 10 <%= @myrank.sysrank %>
</td>
</tr>
<% end %>