Class: PageCommentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PageCommentsController
- Defined in:
- app/controllers/page_comments_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /page_comments POST /page_comments.xml.
-
#destroy ⇒ Object
DELETE /page_comments/1 DELETE /page_comments/1.xml.
-
#edit ⇒ Object
GET /page_comments/1/edit.
-
#new ⇒ Object
GET /page_comments/new GET /page_comments/new.xml.
-
#show ⇒ Object
GET /page_comments/1 GET /page_comments/1.xml.
-
#update ⇒ Object
PUT /page_comments/1 PUT /page_comments/1.xml.
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
POST /page_comments POST /page_comments.xml
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/page_comments_controller.rb', line 46 def create @page_comment = PageComment.new(params[:page_comment]) @page_comment.user_id = current_user.id if current_user @page_comment.semester = AcademicCalendar.current_semester() @page_comment.year = Date.today.year @types = PageCommentType.all respond_to do |format| if @page_comment.save a = PageCommentMailer.comment_update(@page_comment, "created") a.deliver flash[:notice] = 'Comment was successfully created.' format.html { redirect_to(@page_comment.url) } format.xml { render :xml => @page_comment, :status => :created, :location => @page_comment } else format.html { render :action => "new" } format.xml { render :xml => @page_comment.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /page_comments/1 DELETE /page_comments/1.xml
92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/controllers/page_comments_controller.rb', line 92 def destroy @page_comment = PageComment.find(params[:id]) if (:admin, @page_comment.url) @page_comment.destroy respond_to do |format| format.html { redirect_to(page_comments_url) } format.xml { head :ok } end end end |
#edit ⇒ Object
GET /page_comments/1/edit
39 40 41 42 |
# File 'app/controllers/page_comments_controller.rb', line 39 def edit @page_comment = PageComment.find(params[:id]) @types = PageCommentType.all end |
#new ⇒ Object
GET /page_comments/new GET /page_comments/new.xml
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/page_comments_controller.rb', line 27 def new @page_comment = PageComment.new @page_comment.notify_me = true if current_user @types = PageCommentType.all respond_to do |format| format.html # new.html.erb format.xml { render :xml => @page_comment } end end |
#show ⇒ Object
GET /page_comments/1 GET /page_comments/1.xml
16 17 18 19 20 21 22 23 |
# File 'app/controllers/page_comments_controller.rb', line 16 def show @page_comment = PageComment.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @page_comment } end end |
#update ⇒ Object
PUT /page_comments/1 PUT /page_comments/1.xml
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/page_comments_controller.rb', line 69 def update @page_comment = PageComment.find(params[:id]) unless @page_comment.editable?(current_user) flash[:error] = I18n.t(:no_permission) redirect_to(@page_comment.url) and return end @types = PageCommentType.all respond_to do |format| if @page_comment.update_attributes(params[:page_comment]) PageCommentMailer.comment_update(@page_comment, "updated").deliver flash[:notice] = 'Comment was successfully updated.' format.html { redirect_to(@page_comment.url) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @page_comment.errors, :status => :unprocessable_entity } end end end |