Class: My::LinesController
- Inherits:
-
BaseController
- Object
- BaseController
- My::LinesController
- Defined in:
- app/controllers/ship/my/lines_controller.rb
Instance Method Summary collapse
- #add ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #requirement ⇒ Object
- #select ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#add ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/controllers/ship/my/lines_controller.rb', line 18 def add @line = current_user.lines.build(line_params) @line.locations.select(&->(i){ i.position > params[:position].to_i }).each do |i| i.position += 1 end @line.locations.build(position: params[:position].to_i + 1) end |
#create ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/controllers/ship/my/lines_controller.rb', line 30 def create @line = current_user.lines.build(line_params) unless @line.save render :new, locals: { model: @line }, status: :unprocessable_entity end end |
#destroy ⇒ Object
53 54 55 |
# File 'app/controllers/ship/my/lines_controller.rb', line 53 def destroy @line.destroy end |
#edit ⇒ Object
42 43 |
# File 'app/controllers/ship/my/lines_controller.rb', line 42 def edit end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/ship/my/lines_controller.rb', line 5 def index @lines = current_user.lines.order(id: :asc).page(params[:page]) end |
#new ⇒ Object
13 14 15 16 |
# File 'app/controllers/ship/my/lines_controller.rb', line 13 def new @line = current_user.lines.build @line.locations.build(position: 1) end |
#requirement ⇒ Object
9 10 11 |
# File 'app/controllers/ship/my/lines_controller.rb', line 9 def requirement @lines = current_user.lines.order(id: :asc).page(params[:page]) end |
#select ⇒ Object
26 27 28 |
# File 'app/controllers/ship/my/lines_controller.rb', line 26 def select @line = current_user.lines.build end |
#show ⇒ Object
38 39 40 |
# File 'app/controllers/ship/my/lines_controller.rb', line 38 def show @similars = @line.similars end |
#update ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/controllers/ship/my/lines_controller.rb', line 45 def update @line.assign_attributes(line_params) unless @line.save render :edit, locals: { model: @line }, status: :unprocessable_entity end end |