Sha256: df50e7356e7e59e6d26a661261e013eb6bd20725cd1ac0afd841ffbb44b62038
Contents?: true
Size: 1.16 KB
Versions: 23
Compression:
Stored size: 1.16 KB
Contents
class IshManager::EventsController < ::IshManager::ApplicationController def create authorize! :manage, Ish::Event @event = Ish::Event.create( params[:event].permit! ) if @event.persisted? flash[:notice] = "Success." redirect_to action: 'index' else flash[:alert] = "No luck: #{@event.errors.full_messages.join(', ')}." render 'new' end end def edit authorize! :manage, Ish::Event @event = Ish::Event.find params[:id] end def index authorize! :manage, Ish::Event @events = Ish::Event.all if params[:q] @events = @events.where({ :name => /#{params[:q]}/i }) end end def new authorize! :manage, Ish::Event @event = Ish::Event.new end def show authorize! :manage, Ish::Event @event = Ish::Event.find params[:id] end def update authorize! :manage, Ish::Event @event = Ish::Event.find params[:id] @event.update_attributes( params[:event].permit! ) if @event.persisted? flash[:notice] = "Success." redirect_to action: 'index' else flash[:alert] = "No luck: #{@event.errors.full_messages.join(', ')}." render 'edit' end end end
Version data entries
23 entries across 23 versions & 1 rubygems