Class: EntriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- EntriesController
- Defined in:
- app/controllers/entries_controller.rb
Instance Method Summary collapse
-
#archive ⇒ Object
get /entries/archive/(:year)/(:month).
-
#create ⇒ Object
post /entries.
-
#create_repost ⇒ Object
post /entries/:id/reposts.
-
#destroy ⇒ Object
delete /entries/:id.
-
#edit ⇒ Object
get /entries/:id/edit.
-
#index ⇒ Object
get /entries.
-
#new ⇒ Object
get /entries/new.
-
#new_repost ⇒ Object
get /entries/:id/reposts/new.
-
#show ⇒ Object
get /entries/:id.
-
#update ⇒ Object
patch /entries/:id.
Instance Method Details
#archive ⇒ Object
get /entries/archive/(:year)/(:month)
57 58 59 60 61 62 |
# File 'app/controllers/entries_controller.rb', line 57 def archive collect_months unless params[:month].nil? @collection = Entry.archive(params[:year], params[:month]).page_for_visitors current_user, current_page end end |
#create ⇒ Object
post /entries
19 20 21 22 23 24 25 26 |
# File 'app/controllers/entries_controller.rb', line 19 def create @entity = Entry.new creation_parameters if @entity.save redirect_to @entity else render :new, status: :bad_request end end |
#create_repost ⇒ Object
post /entries/:id/reposts
70 71 72 73 74 75 76 77 |
# File 'app/controllers/entries_controller.rb', line 70 def create_repost @news = @entity.news.new(repost_parameters) if @news.save redirect_to @news else render :new_repost, status: :bad_request end end |
#destroy ⇒ Object
delete /entries/:id
48 49 50 51 52 53 54 |
# File 'app/controllers/entries_controller.rb', line 48 def destroy if @entity.update(deleted: true) flash[:notice] = t('entries.destroy.success') end redirect_to entries_path end |
#edit ⇒ Object
get /entries/:id/edit
35 36 |
# File 'app/controllers/entries_controller.rb', line 35 def edit end |
#index ⇒ Object
get /entries
9 10 11 |
# File 'app/controllers/entries_controller.rb', line 9 def index @collection = Entry.page_for_visitors(current_user, current_page) end |
#new ⇒ Object
get /entries/new
14 15 16 |
# File 'app/controllers/entries_controller.rb', line 14 def new @entity = Entry.new end |
#new_repost ⇒ Object
get /entries/:id/reposts/new
65 66 67 |
# File 'app/controllers/entries_controller.rb', line 65 def new_repost @news = @entity.news.new end |
#show ⇒ Object
get /entries/:id
29 30 31 32 |
# File 'app/controllers/entries_controller.rb', line 29 def show @entity.increment! :view_count set_adjacent_entities end |
#update ⇒ Object
patch /entries/:id
39 40 41 42 43 44 45 |
# File 'app/controllers/entries_controller.rb', line 39 def update if @entity.update entity_parameters redirect_to @entity, notice: t('entries.update.success') else render :edit, status: :bad_request end end |