Basically, I need to find a way to have URL/projects/14/tasks/3 actually render URL/projects/14, and call a jquery $('a#task_<%= task.id %>').click()
You can test if the task was reached by a standard HTTP call (non AJAX), and redirect to the project's url, passing in a parameter to autoload the task on load. Since your default case uses a js
format, it's even simpler - you can just test for an html
format:
#TasksController
def show
@task = Task.find(params[:id])
respond_to do |format|
format.html { redirect_to project_path(@task.project_id, :load_task_id => @task.id) }
format.js
end
end
# somewhere in /projects/show partial
<% if params[:load_task_id] %>
<script type="text/javascript">
$(function(){
$('a#task_<%= params[:load_task_id] %>').click()
});
</script>
<% end %>