Class: My::CarsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/ship/my/cars_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
# File 'app/controllers/ship/my/cars_controller.rb', line 13

def create
  @car = current_user.cars.build(car_params)

  unless @car.save
    render :new, locals: { model: @car }, status: :unprocessable_entity
  end
end

#destroyObject



35
36
37
# File 'app/controllers/ship/my/cars_controller.rb', line 35

def destroy
  @car.destroy
end

#editObject



24
25
# File 'app/controllers/ship/my/cars_controller.rb', line 24

def edit
end

#indexObject



5
6
7
# File 'app/controllers/ship/my/cars_controller.rb', line 5

def index
  @cars = current_user.cars.page(params[:page])
end

#newObject



9
10
11
# File 'app/controllers/ship/my/cars_controller.rb', line 9

def new
  @car = current_user.cars.build
end

#showObject



21
22
# File 'app/controllers/ship/my/cars_controller.rb', line 21

def show
end

#updateObject



27
28
29
30
31
32
33
# File 'app/controllers/ship/my/cars_controller.rb', line 27

def update
  @car.assign_attributes(car_params)

  unless @car.save
    render :edit, locals: { model: @car }, status: :unprocessable_entity
  end
end