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
ruby
defupdate@comment = Comment.find(params[:id])
@comment.update_attributes(params[:comment])
response_to do |format|
format.html doif@comment.errors.present?
render :editelse
redirect_to polymorphic_path(@commentable), :notice => "Yay updated!"# or# redirect_to polymorphic_path([@commentable, @comment]), :notice => "Yay i can update and see further down the path!"endendendend
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!
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
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!