Class: Admin::NotesController
Instance Method Summary
collapse
Methods included from BlogHelper
#blog_base_url, #this_blog
Instance Method Details
#create ⇒ Object
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..blank?
unless note.
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
|
#destroy ⇒ Object
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
|
#edit ⇒ Object
20
|
# File 'app/controllers/admin/notes_controller.rb', line 20
def edit; end
|
#index ⇒ Object
9
10
11
|
# File 'app/controllers/admin/notes_controller.rb', line 9
def index
@note = new_note
end
|
#show ⇒ Object
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
|
#update ⇒ Object
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
|