Class: SelectionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- SelectionsController
- Defined in:
- lib/generators/selections_scaffold/templates/selections_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/selections_scaffold/templates/selections_controller.rb', line 20 def create @selection = @parent.children.new(params[:selection]) if @selection.save redirect_to selection_selections_path(@parent), notice: 'Selection was successfully created.' else render action: 'new' end end |
#destroy ⇒ Object
40 41 42 43 44 45 |
# File 'lib/generators/selections_scaffold/templates/selections_controller.rb', line 40 def destroy @selection = Selection.find(params[:id]) @selection.destroy redirect_to selections_url end |
#edit ⇒ Object
16 17 18 |
# File 'lib/generators/selections_scaffold/templates/selections_controller.rb', line 16 def edit @selection = @parent.children.find(params[:id]) end |
#index ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/generators/selections_scaffold/templates/selections_controller.rb', line 4 def index if @parent @selections = @parent.children else @selections = Selection.roots end end |
#new ⇒ Object
12 13 14 |
# File 'lib/generators/selections_scaffold/templates/selections_controller.rb', line 12 def new @selection = @parent.children.new end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/selections_scaffold/templates/selections_controller.rb', line 30 def update @selection = Selection.find(params[:id]) if @selection.update_attributes(params[:selection]) redirect_to selection_selections_path(@parent), notice: 'Selection was successfully updated.' else render action: 'edit' end end |