kaiho/app/controllers/softwares_controller.rb

51 lines
805 B
Ruby
Raw Normal View History

2018-07-22 15:44:29 +00:00
class SoftwaresController < ApplicationController
def index
@softwares = Software.all
end
def new
@software = Software.new
end
def show
@software = Software.find(params[:id])
end
def edit
@software = Software.find(params[:id])
end
def update
@software = Software.find(params[:id])
if @software.update(software_params)
redirect_to @software
else
render 'edit'
end
end
def create
@software = Software.new(software_params)
if @software.save
redirect_to @software
else
render 'new'
end
end
def destroy
@software = Software.find(params[:id])
@software.destroy
redirect_to softwares_path
end
private
def software_params
params.require(:software).permit(:name, :website)
end
end