Use the :include parameter of find to load the associated projects to allow you to sort
eg Task.find(:all, :include => :project, :order => :project_name)
Use the :include parameter of find to load the associated projects to allow you to sort
eg Task.find(:all, :include => :project, :order => :project_name)
<% timeframe.tasks.find(:all, :include => :project, :order => 'projects.name').each do |task| %>
Note that I've changed your block variable to a local rather than an instance variable. When you eager-load an associated model (:include => :project), you need to make sure that the sql fragment in the order option is valid which often means prepending the table name (particularly if the column name appears in more than one of the tables involved... or could in the future).
-Rob
Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com
check_box and its instance variable convention. Use form/fields_for or use check_box_tag
Fred
... which you can overcome by giving an :object option:
<%= check_box('task', 'completed', :object => task, :onchange => remote_function( :url => { :action => 'toggle_completed', :id => task }, :with => "'id=#{task.id}'" )) %>
Do you really need that :with option if the :url has the :id already?
-Rob
Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com
Does the url get generated with :url => { :action => 'toggle_completed', :id => task },
put the task id in somewhere? If your routes are set up, then I'd expect that you'd only be redundant with the explicit ?id= from the :with.
-Rob
Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com