module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
module PostsHelper def posts_smth_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topic_path ( post ) when "link" : posts_link_path ( post ) when "podcast" : posts_podcast_path ( post ) end end def posts_smths_path ( post ) case post. content . class . to_s . downcase when "topic" : posts_topics_path when "link" : posts_links_path when "podcast" : posts_podcasts_path end end end
- <% if can? : edit , @post %>
- <% = link_to "Edit this #IL@post.content.class.to_s.downcase}" , edit_polymorphic_path ( [ : posts , @post . content ] ) ,: class => "b-post-edit_link g-link-no -visited " %>
- <% end %>
- class Posts :: TopicsController < PostsController
- def index
- @posts = Post. topics . find ( : all )
- end
- def new
- @topic = Topic. new
- @topic . build_post
- @selectable_categories = Category. all . collect { | c | [ c. title , c. id ] }
- end
- def edit
- @topic = Topic. find ( params [ : id ] )
- @post = @topic . post
- @selectable_categories = Category. all . collect { | c | [ c. title , c. id ] }
- end
- def create
- @topic = Topic. new ( params [ : topic ] )
- @topic . post . author = current_user
- if @topic . save
- redirect_to post_path ( @topic. post )
- else
- @selectable_categories = Category. all . collect { | c | [ c. title , c. id ] }
- render : action => "new"
- end
- end
- def update
- @topic = Topic. find ( params [ : id ] )
- if @topic . update_attributes ( params [ : topic ] )
- redirect_to post_path ( @topic. post )
- else
- @selectable_categories = Category. all . collect { | c | [ c. title , c. id ] }
- render : action => "edit"
- end
- end
- end
Source: https://habr.com/ru/post/81677/
All Articles