Show More
Commit Description:
add more error message to user list upgrade. Fix #9
Commit Description:
add more error message to user list upgrade. Fix #9
References:
File last commit:
Show/Diff file:
Action:
app/controllers/contests_controller.rb
| 98 lines
| 2.2 KiB
| text/x-ruby
| RubyLexer
|
|
r217 | class ContestsController < ApplicationController | ||
r745 | before_action :admin_authorization | |||
|
r217 | |||
|
r267 | in_place_edit_for :contest, :title | ||
in_place_edit_for :contest, :enabled | ||||
|
r266 | # GET /contests | ||
# GET /contests.xml | ||||
|
r217 | def index | ||
|
r266 | @contests = Contest.all | ||
respond_to do |format| | ||||
format.html # index.html.erb | ||||
format.xml { render :xml => @contests } | ||||
end | ||||
|
r217 | end | ||
|
r266 | # GET /contests/1 | ||
# GET /contests/1.xml | ||||
def show | ||||
@contest = Contest.find(params[:id]) | ||||
|
r217 | |||
|
r266 | respond_to do |format| | ||
format.html # show.html.erb | ||||
format.xml { render :xml => @contest } | ||||
end | ||||
end | ||||
# GET /contests/new | ||||
# GET /contests/new.xml | ||||
def new | ||||
@contest = Contest.new | ||||
respond_to do |format| | ||||
format.html # new.html.erb | ||||
format.xml { render :xml => @contest } | ||||
|
r217 | end | ||
end | ||||
|
r266 | # GET /contests/1/edit | ||
def edit | ||||
@contest = Contest.find(params[:id]) | ||||
end | ||||
# POST /contests | ||||
# POST /contests.xml | ||||
def create | ||||
@contest = Contest.new(params[:contest]) | ||||
respond_to do |format| | ||||
if @contest.save | ||||
flash[:notice] = 'Contest was successfully created.' | ||||
format.html { redirect_to(@contest) } | ||||
format.xml { render :xml => @contest, :status => :created, :location => @contest } | ||||
else | ||||
format.html { render :action => "new" } | ||||
format.xml { render :xml => @contest.errors, :status => :unprocessable_entity } | ||||
end | ||||
|
r247 | end | ||
end | ||||
|
r266 | # PUT /contests/1 | ||
# PUT /contests/1.xml | ||||
def update | ||||
@contest = Contest.find(params[:id]) | ||||
respond_to do |format| | ||||
r617 | if @contest.update_attributes(contests_params) | |||
|
r266 | flash[:notice] = 'Contest was successfully updated.' | ||
format.html { redirect_to(@contest) } | ||||
format.xml { head :ok } | ||||
else | ||||
format.html { render :action => "edit" } | ||||
format.xml { render :xml => @contest.errors, :status => :unprocessable_entity } | ||||
end | ||||
|
r217 | end | ||
|
r266 | end | ||
|
r217 | |||
|
r266 | # DELETE /contests/1 | ||
# DELETE /contests/1.xml | ||||
def destroy | ||||
@contest = Contest.find(params[:id]) | ||||
@contest.destroy | ||||
respond_to do |format| | ||||
format.html { redirect_to(contests_url) } | ||||
format.xml { head :ok } | ||||
end | ||||
|
r217 | end | ||
r617 | private | |||
def contests_params | ||||
params.require(:contest).permit(:title,:enabled,:name) | ||||
end | ||||
|
r217 | end | ||