diff options
author | Jason Lee <huacnlee@gmail.com> | 2015-11-12 08:16:35 +0300 |
---|---|---|
committer | Jason Lee <huacnlee@gmail.com> | 2015-11-12 08:16:35 +0300 |
commit | 1974087114f3f365d16547c8a5c3ec2e03a66104 (patch) | |
tree | bdb754d87349cb4ae7629f537ead5dff8edcebb1 /app/controllers/projects/notes_controller.rb | |
parent | ca25289b78e1b49148438831ad6bf165fa0ce56e (diff) |
Avoid render edit_form in each notes.
Use RJS to render edit note feature.
Before:
```
Rendered projects/notes/_note.html.haml (27.9ms)
Rendered projects/_zen.html.haml (0.3ms)
Rendered projects/notes/_hints.html.haml (0.7ms)
Rendered projects/_md_preview.html.haml (3.9ms)
Rendered projects/notes/_edit_form.html.haml (6.9ms)
Rendered projects/notes/_note.html.haml (17.7ms)
Rendered projects/_zen.html.haml (0.3ms)
Rendered projects/notes/_hints.html.haml (0.6ms)
Rendered projects/_md_preview.html.haml (3.4ms)
Rendered projects/notes/_edit_form.html.haml (7.0ms)
```
After:
```
Rendered projects/notes/_note.html.haml (13.8ms)
Rendered projects/notes/_note.html.haml (7.1ms)
Rendered projects/notes/_note.html.haml (9.5ms)
Rendered projects/notes/_note.html.haml (8.5ms)
```
This change reduce at least 6ms * N ('N' - number of notes).
Diffstat (limited to 'app/controllers/projects/notes_controller.rb')
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 41cd08c93c6..0c98e2f1bfd 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -3,7 +3,7 @@ class Projects::NotesController < Projects::ApplicationController before_action :authorize_read_note! before_action :authorize_create_note!, only: [:create] before_action :authorize_admin_note!, only: [:update, :destroy] - before_action :find_current_user_notes, except: [:destroy, :delete_attachment] + before_action :find_current_user_notes, except: [:destroy, :edit, :delete_attachment] def index current_fetched_at = Time.now.to_i @@ -29,6 +29,11 @@ class Projects::NotesController < Projects::ApplicationController end end + def edit + @note = note + render layout: false + end + def update @note = Notes::UpdateService.new(project, current_user, note_params).execute(note) |