Hello all. I've set up an inventory app and I want to be able to have
the index file display ether everything in inventory or only items on
order. So I want to populate @spares with the appropriate content then
pass it to index.html.erb
Is this the right approach? If so how do put logic into the controller
to populate @spares ?
Any help appreciated!
...Bill

------------spares_controller.rb
def index
@spares = Spare.find(:all) <--do this to see total inventory
@spares = Spare.find(:all, :conditions => ["state = ?", "On Order"])
<--do this to see what's on order
...
end

-------------index.html.erb
<% for spare in @spares %>
  <tr>
    <td><%=h spare.name %></td>
    <td><%=h spare.partno %></td>
    <td><%=h spare.state %></td>
...
  </tr>
<% end %>
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to