Skip to content

Instantly share code, notes, and snippets.

@geocodinglife
Created April 11, 2017 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geocodinglife/3acad696d714d09770c063426395f257 to your computer and use it in GitHub Desktop.
Save geocodinglife/3acad696d714d09770c063426395f257 to your computer and use it in GitHub Desktop.
class RoomsController < ApplicationController
def index
@rooms = Room.all
end
def show
@room = Room.find(params[:id])
end
def new
@room = Room.new
end
def edit
@room = Room.find(params[:id])
end
def create
@room = Room.new(room_params)
if @room.save
redirect_to @room
else
render 'new'
end
end
def update
@room = Room.find(params[:id])
if @room.update(room_params)
redirect_to @room
else
render 'edit'
end
end
def destroy
@room = Article.find(params[:id])
@room.destroy
redirect_to articles_path
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment