Class: ContentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ContentsController
- Defined in:
- app/controllers/contents_controller.rb
Instance Method Summary collapse
-
#edit ⇒ Object
GET /contents/edit.
- #help ⇒ Object
-
#update ⇒ Object
POST /contents/update.
Instance Method Details
#edit ⇒ Object
GET /contents/edit
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/contents_controller.rb', line 4 def edit if $editable_content_authorization if request.xhr? logger.debug("[Content.Edit] name = #{params[:p_name]}, controller = #{params[:p_controller]}, action = #{params[:p_action]}") @content = EcContent.first( :conditions => { :name => params[:p_name], :controller => params[:p_controller], :action => params[:p_action]} ) val = {:id => @content.id, :content => @content.body}.to_json logger.debug("[Content.Edit] return json = #{val.inspect}") render :json => val else flash[:error] = 'This action expects an AJAX call.' redirect_to root_url + "?nonajax" end else flash[:error] = 'You are not authorized to perform that action.' redirect_to root_url + "?unauthorized" end end |
#help ⇒ Object
46 47 48 49 50 51 |
# File 'app/controllers/contents_controller.rb', line 46 def help unless $editable_content_authorization flash[:error] = 'You are not authorized to perform that action.' redirect_to root_url end end |
#update ⇒ Object
POST /contents/update
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/contents_controller.rb', line 24 def update if $editable_content_authorization if request.xhr? @content = EcContent.find(params[:p_id]) new_content = params[:p_content] logger.debug("[Content.Update] @content.id = #{@content.id}, new_content = #{new_content.inspect}") if @content.update_attributes(:body=>new_content) render :text => getInnerContent(@content.name, @content.controller, @content.action) else render :text => "fail", :status => 500 end else flash[:error] = 'This action expects an AJAX call.' redirect_to root_url end else flash[:error] = 'You are not authorized to perform that action.' redirect_to root_url end end |