Find_by_sql + partials question

Ok now that I have find_by_sql love working for my “Top 10 List” I
want to make them a bit more DRY. Tis is what I have so far:


 def self.topfish

length,species.multiplier*length as score,caught_on from entries join
species on species_id = where species_id = ? order by
score DESC LIMIT 10", species]

This data is spit out as part of a partial:


<% for ling in @topfish %>

<% end %>

Main Viw:

<%= render :partial => 'topfish', :locals => { :species => "1" } %>


def list
@entries = Entry.mine
@topfish = Entry.topfish

Now when I load the list I get this - “wrong number of arguments (0
for 1)” So I know I need to pass a species_id in with my partial bu
it does not appear to work with locals. Any pointers would be
helpful, I have spent the last few hours hunting around but I can’t
figure out why this is not working.

What I want to do is pass a variable in to the find_by_sql using a
local in the main view. This way I can update that when a new fish is
added in a given species.

  • Bill
<%=h %> - <%=h ling.length %> Inches - <%=h ling.score %> Points - <%=h ling.caught_on.strftime("%m-%d-%Y") %>

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