Class: ForumPostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ForumPostsController
- Defined in:
- app/controllers/forum_posts_controller.rb
Overview
This RESTful controller is used to orchestrate and control the flow of the application relating to ForumPost objects. It offers special actions to allow registered users to create, update and delete the posts they created.
Constant Summary
Constant Summary
Constants inherited from ApplicationController
ApplicationController::SEARCH_SCOPE_SEPARATOR
Instance Method Summary (collapse)
-
- (Object) create
-
POST /forum_topics/1/forum_threads/1/forum_posts
-
POST /forum_topics/1/forum_threads/1/forum_posts.xml.
-
-
- (Object) destroy
-
DELETE /forum_topics/1/forum_threads/1/forum_posts/1
-
DELETE /forum_topics/1/forum_threads/1/forum_posts/1.xml.
-
-
- (Object) edit
-
GET /forum_topics/1/forum_threads/1/forum_posts/1/edit.
-
-
- (Object) new
-
GET /forum_topics/1/forum_threads/1/forum_posts/new.
-
-
- (Object) show
-
GET /forum_topics/1/forum_threads/1/forum_posts/1
-
GET /forum_topics/1/forum_threads/1/forum_posts/1.xml.
-
-
- (Object) update
-
PUT /forum_topics/1/forum_threads/1/forum_posts/1
-
PUT /forum_topics/1/forum_threads/1/forum_posts/1.xml.
-
Methods inherited from ApplicationController
#all_changes, #changes, #synonyms
Methods included from RoleRequirementSystem
Instance Method Details
- (Object) create
-
POST /forum_topics/1/forum_threads/1/forum_posts
-
POST /forum_topics/1/forum_threads/1/forum_posts.xml
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/forum_posts_controller.rb', line 44 def create @forum_post = @forum_thread.forum_posts.build(params[:forum_post]) @forum_post.user = current_user respond_to do |format| if @forum_post.save format.html { redirect_to [ @forum_topic, @forum_thread ] } format.xml { render :xml => @forum_post, :status => :created, :location => @forum_post } else format.html { render :action => :new } format.xml { render :xml => @forum_post.errors, :status => :unprocessable_entity } end end end |
- (Object) destroy
-
DELETE /forum_topics/1/forum_threads/1/forum_posts/1
-
DELETE /forum_topics/1/forum_threads/1/forum_posts/1.xml
76 77 78 79 80 81 82 83 |
# File 'app/controllers/forum_posts_controller.rb', line 76 def destroy @forum_post.destroy respond_to do |format| format.html { redirect_to [ @forum_topic, @forum_thread ] } format.xml { head :ok } end end |
- (Object) edit
-
GET /forum_topics/1/forum_threads/1/forum_posts/1/edit
39 40 |
# File 'app/controllers/forum_posts_controller.rb', line 39 def edit end |
- (Object) new
-
GET /forum_topics/1/forum_threads/1/forum_posts/new
33 34 35 36 |
# File 'app/controllers/forum_posts_controller.rb', line 33 def new @forum_post = @forum_thread.forum_posts.build @forum_post.user_name = current_user.login if logged_in? end |
- (Object) show
-
GET /forum_topics/1/forum_threads/1/forum_posts/1
-
GET /forum_topics/1/forum_threads/1/forum_posts/1.xml
25 26 27 28 29 30 |
# File 'app/controllers/forum_posts_controller.rb', line 25 def show respond_to do |format| format.html { redirect_to [ @forum_topic, @forum_thread ] } format.xml { render :xml => @forum_post } end end |
- (Object) update
-
PUT /forum_topics/1/forum_threads/1/forum_posts/1
-
PUT /forum_topics/1/forum_threads/1/forum_posts/1.xml
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/forum_posts_controller.rb', line 61 def update respond_to do |format| if @forum_post.update_attributes(params[:forum_post]) format.html { redirect_to [ @forum_topic, @forum_thread ] } format.xml { head :ok } else format.html { render :action => :edit } format.xml { render :xml => @forum_post.errors, :status => :unprocessable_entity } end end end |