Class: MongoidForums::ForumsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- MongoidForums::ForumsController
- Defined in:
- app/controllers/mongoid_forums/forums_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #index ⇒ Object
-
#new ⇒ Object
Note: This is not an action to make a new Forum! it is to create a new TOPIC within a forum.
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 25 def create @forum = Forum.find(params[:forum_id]) @topic = Topic.new @topic.name = topic_params[:name] @topic.user = mongoid_forums_user.id @topic.forum = @forum.id @post = Post.new @post.user = mongoid_forums_user.id @post.text = topic_params[:posts][:text] @topic.posts << @post if @topic.save && @topic.posts.first.save flash[:notice] = "Topic created successfully" redirect_to @topic else flash.now.alert = "Topic could not be created" render :action => "new" end end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 5 def index @categories = Category.all.order_by([:order, :asc]) end |
#new ⇒ Object
Note: This is not an action to make a new Forum! it is to create a new TOPIC within a forum
19 20 21 22 23 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 19 def new @forum = Forum.find(params[:forum_id]) @topic = Topic.new @topic.forum = @forum.id end |
#show ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 9 def show @forum = Forum.find(params[:id]) register_view @topics = @forum.topics @topics = @topics.by_pinned_or_most_recent_post.page(params[:page]).per(MongoidForums.per_page) end |