RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: aurelplouf
Hello I learned a lot from this episode about Polymorphic association, which always seemed a bit mysterious!
I think what the episode is really missing, is an explanation about polymorphic_url or polymorphic_path in order to recognize which model you wish to redirect. It is extremely helpful to understand this method especially when nesting multiple polymorphic models (see documentation). For example
@comment = Comment.find(params[:id])
response_to do |format|
redirect_to polymorphic_path(@commentable), :notice => "Yay updated!"
# redirect_to polymorphic_path([@commentable, @comment]), :notice => "Yay i can update and see further down the path!"
sorry if messed up the comment markup ^^
Thank you Ryan for the wonderful videos. I have been watching your masterpieces for a few years. I love your Pro and Revised versions, Keep it up!