diff options
author | Ben Harris <ben@tilde.team> | 2021-08-21 19:30:19 -0400 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2021-08-21 19:30:33 -0400 |
commit | 819a3edae405227f11283ad494a7f4ca9c771467 (patch) | |
tree | 8da57ee1777f992f4f13879795916615009f6a53 /app/controllers/machines_controller.rb |
init
Diffstat (limited to 'app/controllers/machines_controller.rb')
-rw-r--r-- | app/controllers/machines_controller.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/app/controllers/machines_controller.rb b/app/controllers/machines_controller.rb new file mode 100644 index 0000000..24c90e7 --- /dev/null +++ b/app/controllers/machines_controller.rb @@ -0,0 +1,49 @@ +class MachinesController < ApplicationController + def index + @machines = Machine.order("name") + end + + def show + @machine = Machine.find(params[:id]) + end + + def new + @machine = Machine.new + end + + def create + @machine = Machine.new(machine_params) + + if @machine.save + redirect_to @machine + else + render :new + end + end + + def edit + @machine = Machine.find(params[:id]) + end + + def update + @machine = Machine.find(params[:id]) + + if @machine.update(machine_params) + redirect_to @machine + else + render :edit + end + end + + def destroy + @machine = Machine.find(params[:id]) + @machine.destroy + + redirect_to root_path + end + + private + def machine_params + params.require(:machine).permit(:name, :edition) + end +end |