Class: ListsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ListsController
- Defined in:
- app/controllers/lists_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/lists_controller.rb', line 32 def create @list = List.new(list_params.merge(owner: current_user)) @list respond_to do |format| format.html do if @list.save redirect_to @list, notice: t(".success") else render Views::Lists::New.new(list: @list), status: :unprocessable_content end end end end |
#destroy ⇒ Object
58 59 60 61 62 63 |
# File 'app/controllers/lists_controller.rb', line 58 def destroy @list.destroy! respond_to do |format| format.html { redirect_to lists_path, notice: t(".success"), status: :see_other } end end |
#edit ⇒ Object
26 27 28 29 30 |
# File 'app/controllers/lists_controller.rb', line 26 def edit respond_to do |format| format.html { render Views::Lists::Edit.new(list: @list) } end end |
#index ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/lists_controller.rb', line 5 def index @lists = policy_scope(current_user.lists).all respond_to do |format| format.html { render Views::Lists::Index.new(lists: @lists) } end end |
#new ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/controllers/lists_controller.rb', line 18 def new @list = List.new @list respond_to do |format| format.html { render Views::Lists::New.new(list: @list) } end end |
#show ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/lists_controller.rb', line 12 def show respond_to do |format| format.html { render Views::Lists::Show.new(list: @list) } end end |
#update ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/lists_controller.rb', line 46 def update respond_to do |format| format.html do if @list.update(list_params(list: @list)) redirect_back_or_to @list, notice: (@list.special? ? nil : t(".success")), status: :see_other else render Views::Lists::Edit.new(list: @list), status: :unprocessable_content end end end end |