Sha256: 9587d58b8c6f45ad8649f2e8f4556e10e813bd17f2fd5c86f5515547db36badf
Contents?: true
Size: 1.77 KB
Versions: 15
Compression:
Stored size: 1.77 KB
Contents
class PublicHolidaysController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @public_holiday_pages, @public_holidays = paginate :public_holidays, :per_page => 10 end def show @public_holiday = PublicHoliday.find(params[:id]) end def new @public_holiday = PublicHoliday.new end def create @public_holiday = PublicHoliday.new(params[:public_holiday]) if @public_holiday.save flash[:notice] = 'PublicHoliday was successfully created.' redirect_to :action => 'list' else render :action => 'new' end end def edit @public_holiday = PublicHoliday.find(params[:id]) end def update @public_holiday = PublicHoliday.find(params[:id]) if @public_holiday.update_attributes(params[:public_holiday]) flash[:notice] = 'PublicHoliday was successfully updated.' redirect_to :action => 'show', :id => @public_holiday else render :action => 'edit' end end def destroy PublicHoliday.find(params[:id]).destroy redirect_to :action => 'list' end def mark if params[:public_holiday] on = params[:public_holiday][:on] marked = params[:public_holiday][:marked] == '1' @public_holiday = PublicHoliday.find(:first, :conditions => {:on => on}) if marked if @public_holiday.nil? PublicHoliday.create!(:on => on) end else if @public_holiday @public_holiday.destroy end end end back_or_redirect_to :controller => 'works', :action => :daily_work_sheet end end
Version data entries
15 entries across 15 versions & 1 rubygems