91 lines
2.1 KiB
Ruby
91 lines
2.1 KiB
Ruby
class ListsController < ApplicationController
|
|
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
|
# GET /lists
|
|
# GET /lists.json
|
|
def index
|
|
@lists = List.all
|
|
|
|
respond_to do |format|
|
|
format.html # index.html.erb
|
|
format.json { render json: @lists }
|
|
end
|
|
end
|
|
|
|
# GET /lists/1
|
|
# GET /lists/1.json
|
|
def show
|
|
@list = List.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
format.html # show.html.erb
|
|
format.json { render json: @list }
|
|
end
|
|
end
|
|
|
|
# GET /lists/new
|
|
# GET /lists/new.json
|
|
def new
|
|
@list = List.new
|
|
|
|
respond_to do |format|
|
|
format.html # new.html.erb
|
|
format.json { render json: @list }
|
|
end
|
|
end
|
|
|
|
# GET /lists/1/edit
|
|
def edit
|
|
@list = List.find(params[:id])
|
|
end
|
|
|
|
# POST /lists
|
|
# POST /lists.json
|
|
def create
|
|
@list = List.new(params[:list])
|
|
|
|
respond_to do |format|
|
|
if @list.save
|
|
format.html { redirect_to @list, notice: t('action.create.successfull', model: List.model_name.human) }
|
|
format.json { render json: @list, status: :created, location: @list }
|
|
else
|
|
format.html { render action: "new" }
|
|
format.json { render json: @list.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PUT /lists/1
|
|
# PUT /lists/1.json
|
|
def update
|
|
@list = List.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
if @list.update_attributes(params[:list])
|
|
format.html { redirect_to @list, notice: t('action.update.successfull', model: List.model_name.human) }
|
|
format.json { head :no_content }
|
|
else
|
|
format.html { render action: "edit" }
|
|
format.json { render json: @list.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /lists/1
|
|
# DELETE /lists/1.json
|
|
def destroy
|
|
@list = List.find(params[:id])
|
|
@list.destroy
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to lists_url, notice: t('action.destroy.successfull', model: List.model_name.human) }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def set_relation_options
|
|
@tables = Table.all
|
|
end
|
|
end
|