Sha256: c502ca422f8b1d3f929638d875e64f624df57147852f69c0f8e81392fe244c64
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 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 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
my_forum-0.0.1.beta2 | app/controllers/my_forum/topics_controller.rb |
my_forum-0.0.1.beta1 | app/controllers/my_forum/topics_controller.rb |