Sha256: 3de90efc856084258f053f3089f5221cec828c568550f9429dd39c5a4f837dd7

Contents?: true

Size: 584 Bytes

Versions: 2

Compression:

Stored size: 584 Bytes

Contents

require_dependency "my_forum/application_controller"

module MyForum
  class PostsController < ApplicationController
    before_filter :find_topic
    before_filter :find_forum

    def create
      post = @topic.posts.build(post_params)
      post.user = current_user
      post.save
      redirect_to forum_topic_path(@forum, @topic)
    end

    private

    def find_topic
      @topic = Topic.find(params[:topic_id])
    end

    def find_forum
      @forum = Forum.find(params[:forum_id])
    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/posts_controller.rb
my_forum-0.0.1.beta1 app/controllers/my_forum/posts_controller.rb