I'm allowing users to create a 'Question' from different pages in the app, and want them to be redirected to the right page after the new question is saved. Since one page has a params[:id] and one doesn't, I thought I'd use that to differentiate between the different redirects.
Here's what I was trying to do in my Questions controller:
respond_to do |format|
if @question.save
if params[:id].nil?
format.html {redirect_to :controller => 'home', :action => 'show', :username => question.directed_to}
else
format.html {redirect_to :controller => 'mentions', :action => 'show', :id => question.topic}
end
else
...
end
Thanks very much, I'm still new to this.