Forum: Ruby on Rails find_by_sql + partials question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bill P. (Guest)
on 2006-01-11 01:56
(Received via mailing list)
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 %>
<table border ="0" CELLSPACING="0">
<tr class="<%= alternate %>">
   <td><%=h %> - </td>
   <td><%=h ling.length %> Inches - </td>
   <td><%=h ling.score %> Points - </td>
   <td><%=h ling.caught_on.strftime("%m-%d-%Y") %></td>
<% end %>

Main Viw:

<div id="topfish">
	<%= 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
This topic is locked and can not be replied to.