(accessed by /tasks/active and tasks/complete respectively).
@tasks = Task.all(:complete => false)
@tasks = Task.all(:complete => true)
The views for both of these actions have a form for creating a new task
which submits via ajax. The view looks something like the following:
@task = Task.new(params[:task])
respond_with(@task, :location => tasks_path) do |format|
format.js # reload task list
My question is about the "reload task list" line. When the task is created,
I need to reload the task list. If the task was created from the "completed"
page, we would want to reload the "completed" data set, and if it was
created from the "active" page we would want to reload the "active" data
What's the most DRY way to detect which page the task was created from and
reload the appropriate data set?
I could check whether "/active" or "/complete" is in the HTTP referrer, but
that feels kind of hack-ish.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/WGTUB2sKO10J.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.