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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 38 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 11 12 13 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 8 def index @categories = Category.sorted unless mongoid_forums_user.mongoid_forums_admin? @categories = @categories.enabled end end |
#new ⇒ Object
Note: This is not an action to make a new Forum! it is to create a new TOPIC within a forum
28 29 30 31 32 33 34 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 28 def new @forum = Forum.find(params[:forum_id]) :create_topic, @forum @topic = Topic.new @topic.forum = @forum.id end |
#show ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/mongoid_forums/forums_controller.rb', line 15 def show @forum = Forum.find(params[:id]) register_view @topics = @forum.topics unless mongoid_forums_user.mongoid_forums_admin? @topics = @topics.enabled end @topics = @topics.by_pinned_or_most_recent_post.page(params[:page]).per(MongoidForums.per_page) end |