Class: Admin::NotesController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/notes_controller.rb

Instance Method Summary collapse

Methods included from BlogHelper

#blog_base_url, #this_blog

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/admin/notes_controller.rb', line 20

def create
  note = new_note

  note.state = 'published'
  note.attributes = params[:note].permit!
  note.text_filter ||= current_user.default_text_filter
  note.published_at ||= Time.zone.now
  if note.save
    if params[:push_to_twitter] && note.twitter_id.blank?
      unless note.send_to_twitter
        flash[:error] = I18n.t('errors.problem_sending_to_twitter')
        flash[:error] += " : #{note.errors.full_messages.join(' ')}"
      end
    end
    flash[:notice] = I18n.t('notice.note_successfully_created')
  else
    flash[:error] = note.errors.full_messages
  end
  redirect_to admin_notes_url
end

#destroyObject



47
48
49
50
51
# File 'app/controllers/admin/notes_controller.rb', line 47

def destroy
  @note.destroy
  flash[:notice] = I18n.t('admin.base.successfully_deleted', name: 'note')
  redirect_to admin_notes_url
end

#editObject



18
# File 'app/controllers/admin/notes_controller.rb', line 18

def edit; end

#indexObject



7
8
9
# File 'app/controllers/admin/notes_controller.rb', line 7

def index
  @note = new_note
end

#showObject



11
12
13
14
15
16
# File 'app/controllers/admin/notes_controller.rb', line 11

def show
  unless @note.access_by?(current_user)
    flash[:error] = I18n.t('admin.base.not_allowed')
    redirect_to admin_notes_url
  end
end

#updateObject



41
42
43
44
45
# File 'app/controllers/admin/notes_controller.rb', line 41

def update
  @note.attributes = params[:note].permit!
  @note.save
  redirect_to admin_notes_url
end