Class: NotesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- NotesController
- Defined in:
- lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
before_action :xload_current_ma_user, only: [:destroy].
- #mail ⇒ Object
- #my ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 21 def create @note = Note.new( title: $xvars["new_note"]["title"], body: $xvars["new_note"]["body"], user_id: $xvars["user_id"]) @note.save! # if @note.save! # format.html { redirect_to @note, notice: 'Sample was successfully created.' } # format.json { render :show, status: :created, location: @note } # else # format.html { render :new } # format.json { render json: @note.errors, status: :unprocessable_entity } # end redirect_to @note end |
#delete ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 51 def delete # called by freemind # Tobe called from other controller:jinda @note_id = $xvars["select_note"] ? $xvars["select_note"]["id"] : $xvars["p"]["note_id"] @note = Note.find(@note_id) @note.destroy end |
#destroy ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 59 def destroy # called by rails menu my if current_ma_user.role.upcase.split(',').include?("A") || current_ma_user == @note.user @note.destroy end redirect_to :action=>'my' end |
#edit ⇒ Object
16 17 18 19 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 16 def edit @note = Note.find(params[:id]) @page_title = 'Edit Note' end |
#index ⇒ Object
before_action :xload_current_ma_user, only: [:destroy]
5 6 7 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 5 def index @notes = Note.desc(:created_at).page(params[:page]).per(10) end |
#mail ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 67 def mail NoteMailer.gmail( $xvars["display_mail"]["body"], $xvars["select_note"]["email"], $xvars["display_mail"]["title"], xload_current_ma_user.email) end |
#my ⇒ Object
9 10 11 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 9 def my @notes = Note.where(user_id: current_ma_user).desc(:created_at).page(params[:page]).per(10) end |
#show ⇒ Object
13 14 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 13 def show end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb', line 39 def update # $xvars["select_note"] and $xvars["edit_note"] # These are variables. # They contain everything that we get their forms select_note and edit_note note_id = $xvars["select_note"] ? $xvars["select_note"]["id"] : $xvars["p"]["note_id"] @note = Note.find(note_id) @note.update(title: $xvars["edit_note"]["title"], body: $xvars["edit_note"]["body"]) redirect_to @note end |