Class: MongoidForums::PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- MongoidForums::PostsController
- Defined in:
- app/controllers/mongoid_forums/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/mongoid_forums/posts_controller.rb', line 11 def create @post = Post.new @post.text = params[:post][:text] @post.topic = params[:topic_id] @post.user = mongoid_forums_user.id @post.reply_to_id = params[:post][:reply_to_id] if @post.reply_to_id && @post.reply_to_id == @post.topic.posts.first.id flash[:alert] = "You may not quote the original post" redirect_to @post.topic return end if @post.topic.locked flash[:alert] = "You may not post on a locked topic" redirect_to @post.topic return end if @post.save @post.topic.alert_subscribers(mongoid_forums_user.id) flash[:notice] = "Reply created successfully" redirect_to @post.topic else flash.now.alert = "Reply could not be created" render :action => "new" end end |
#destroy ⇒ Object
60 61 |
# File 'app/controllers/mongoid_forums/posts_controller.rb', line 60 def destroy end |
#edit ⇒ Object
45 46 |
# File 'app/controllers/mongoid_forums/posts_controller.rb', line 45 def edit end |
#new ⇒ Object
5 6 7 8 9 |
# File 'app/controllers/mongoid_forums/posts_controller.rb', line 5 def new @topic = Topic.find(params[:topic_id]) @post = Post.new @post.topic = @topic.id end |
#show ⇒ Object
42 43 |
# File 'app/controllers/mongoid_forums/posts_controller.rb', line 42 def show end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/mongoid_forums/posts_controller.rb', line 48 def update @post = current_resource if @post.update_attributes(post_params) flash[:notice] = "Reply updated successfully" redirect_to current_resource.topic else flash[:notice] = "Reply could not be updated" render :action => "edit" end end |