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
Note: This is not an action to make a new Forum! it is to create a new TOPIC within a forum.
- #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
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
Note: This is not an action to make a new Forum! it is to create a new TOPIC within a forum
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 32 def create @forum = Forum.find(params[:forum_id]) :create_topic, @forum @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] = t("mongoid_forums.topic.created") redirect_to @topic else flash.now.alert = t("mongoid_forums.topic.not_created") render :action => "new" end end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 8 def index @categories = Category.asc(:position) end |
#new ⇒ Object
Note: This is not an action to make a new Forum! it is to create a new TOPIC within a forum
22 23 24 25 26 27 28 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 22 def new @forum = Forum.find(params[:forum_id]) :create_topic, @forum @topic = Topic.new @topic.forum = @forum.id end |
#show ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 12 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 |