I have two controllers, orders and tasks – each order has many tasks.
In my orders show view, I list all the related tasks for the order.
My issue is that I want to restrict the output – eg. only list tasks with a status = 1
In my orders controller I tried this:
@tasks = Task.find(:all, :conditions => [:status => '1'])
But I get an error:
undefined method `%' for {:status=>"1"}:Hash
I also don’t really know how to call this. In my orders show view I tried this:
<% @task.tasks.each do |task| %>
<li>
<%= task.title %> <%= task.dueddate %>
</li>
<% end %>
Can you help a flailing newbie 🙂
You really need to check query interface in rails 3
http://railscasts.com/episodes/202-active-record-queries-in-rails-3
http://railscasts.com/episodes/215-advanced-queries-in-rails-3
Btwn your solution is:-