Class: Commenteux::NotesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Commenteux::NotesController
- Defined in:
- app/controllers/commenteux/notes_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/commenteux/notes_controller.rb', line 26 def create resource = fetch_resource fetch_params comment_params roles = '' if @roles roles = '&roles=' + @roles comment_role = params[:comments][:role] end get_comment_model_method(resource, comment_role).create(comment_params) if @display_list_notes == "true" redirect_to "/commenteux/#{@resource.downcase}/#{@resource_id}?parent_div=" + @parent_div + roles + "&display_list_notes=#{@display_list_notes}" else render json: get_comments(resource, manage_roles_parameter(params[:roles])) end end |
#destroy ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/commenteux/notes_controller.rb', line 79 def destroy begin resource = fetch_resource @comment = get_comment_model_method(resource, params[:comment_role]).find(params[:id]) @comment.destroy! #flash[:success] = "Commentaire supprimé avec succès" rescue ActiveRecord::RecordNotFound #flash[:error] = "Ce commentaire n'existe plus." end respond_to do |format| format.js end end |
#edit ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/controllers/commenteux/notes_controller.rb', line 45 def edit resource = fetch_resource fetch_params @list_roles = manage_roles_parameter(params[:roles]) @comment = get_comment_model_method(resource, params[:comment_role]).find(params[:id]) render :layout => false if request.xhr? end |
#index ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/controllers/commenteux/notes_controller.rb', line 7 def index resource = fetch_resource fetch_params list_roles = manage_roles_parameter(params[:roles]) @comments = get_comments(resource, list_roles) if @display_list_notes == "true" render :layout => false if request.xhr? end |
#new ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/commenteux/notes_controller.rb', line 16 def new resource = fetch_resource fetch_params @list_roles = manage_roles_parameter(params[:roles]) role = @list_roles[0][0] if @list_roles and @list_roles.length > 0 @comment = get_comment_model_method(resource, role).new render :layout => false if request.xhr? end |
#update ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/commenteux/notes_controller.rb', line 54 def update begin resource = fetch_resource fetch_params comment_params roles = '' unless @roles.blank? roles = '&roles=' + @roles comment_role = params[:comments][:role] end @comment = get_comment_model_method(resource, comment_role).find(params[:id]) if @comment.update(comment_params) #flash[:success] = "Commentaire modifié avec succès" redirect_to "/commenteux/#{@resource.downcase}/#{@resource_id}?parent_div=" + @parent_div + roles + "&display_list_notes=#{@display_list_notes}" else #flash[:danger] = "Impossible de sauvegarder le commentaire" render action: 'edit', :layout => false end rescue ActiveRecord::RecordNotFound #flash[:danger] = "Ce commentaire n'existe plus." redirect_to "/commenteux/#{@resource.downcase}/#{@resource_id}?parent_div=" + @parent_div + roles + "&display_list_notes=#{@display_list_notes}" end end |