Sha256: d27f731ac4c98ecca12aabf16936ac67e88ff1547b3f9e553a4f35d526adc758
Contents?: true
Size: 1.12 KB
Versions: 25
Compression:
Stored size: 1.12 KB
Contents
require_dependency "my_forum/application_controller" module MyForum class TopicsController < ApplicationController before_filter :find_forum, only: [:new, :create, :show] def new @topic = @forum.topics.build end def show @topic = Topic.find(params[:id]) check_access_permissions(@topic) @topic_posts = @topic.posts.paginate(per_page: 16, page: params[:page]) @new_post = Post.new #TODO if quick_answer_enabled @topic.mark_as_read(current_user, @topic_posts.last) @topic.increment!(:views) if current_user end def create raise unless current_user #TODO ! topic = @forum.topics.build(topic_params) post = topic.posts.build(post_params) post.user = current_user topic.save post.save topic.mark_as_read(current_user, post) redirect_to forum_path(@forum) end private def find_forum @forum = Forum.find(params[:forum_id]) end def topic_params params.require(:topic).permit(:name, :description) end def post_params params.require(:post).permit(:text) end end end
Version data entries
25 entries across 25 versions & 1 rubygems