Class: Motor::NotesController
- Inherits:
-
ApiBaseController
- Object
- ActionController::API
- ApiBaseController
- Motor::NotesController
- Defined in:
- app/controllers/motor/notes_controller.rb
Instance Method Summary collapse
Methods included from CurrentAbility
Methods included from CurrentUserMethod
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/motor/notes_controller.rb', line 21 def create Motor::Notes::Persist.call(@note, current_user) Motor::NotifyNoteMentionsJob.perform_later(@note, current_user) render json: { data: Motor::ApiQuery::BuildJson.call(@note, params, current_ability) } end |
#destroy ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/motor/notes_controller.rb', line 37 def destroy @note.update!(deleted_at: Time.current) Motor::NotesChannel.broadcast_to( @note.values_at(:record_type, :record_id).join(':'), ['remove', @note.as_json(only: %i[id body created_at updated_at])] ) head :ok end |
#index ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/motor/notes_controller.rb', line 11 def index @notes = Motor::ApiQuery.call(@notes.active.order(created_at: :asc), params) render json: { data: Motor::ApiQuery::BuildJson.call(@notes, params, current_ability) } end |
#show ⇒ Object
17 18 19 |
# File 'app/controllers/motor/notes_controller.rb', line 17 def show render json: { data: Motor::ApiQuery::BuildJson.call(@note, params, current_ability) } end |
#update ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/motor/notes_controller.rb', line 28 def update @note.assign_attributes(note_params) Motor::Notes::Persist.call(@note, current_user) Motor::NotifyNoteMentionsJob.perform_later(@note, current_user) render json: { data: Motor::ApiQuery::BuildJson.call(@note, params, current_ability) } end |