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



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

def create
  note = new_note

  note.state = "published"
  note.attributes = params[:note].permit!
  note.text_filter ||= 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



49
50
51
52
53
# File 'app/controllers/admin/notes_controller.rb', line 49

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

#editObject



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

def edit; end

#indexObject



9
10
11
# File 'app/controllers/admin/notes_controller.rb', line 9

def index
  @note = new_note
end

#showObject



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

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

#updateObject



43
44
45
46
47
# File 'app/controllers/admin/notes_controller.rb', line 43

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