Sha256: 2cc48cf1adc9634adebde81629ee6122d2d97ef46149b209798bf0a00754127f
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
class Eventable::PricesController < Eventable::EventableController before_filter :get_event before_filter :get_prices, :only => [:index] before_filter :get_price, :only => [:show, :edit, :update, :destroy] before_filter :new_price, :only => [:new, :create] def create if @price.update_attributes(params[:eventable_price]) try_after_callback do flash[:notice] = 'Price was successfully added.' redirect_to (if params[:list] eventable_event_pricelist_path @event else eventable_event_price_path @event, @price end) end else try_after_callback :fail do render :action => "new" end end end def update if @price.update_attributes(params[:eventable_price]) try_after_callback do flash[:notice] = 'Price was successfully updated.' redirect_to (if params[:list] eventable_event_pricelist_path @event else eventable_event_price_path @event, @price end) end else try_after_callback :fail do render :action => "edit" end end end def destroy @price.destroy try_after_callback do redirect_to (if params[:list] eventable_event_pricelist_path @event else eventable_event_prices_path @event end) end end private def model @event.prices end def get_prices @prices = model.all end def get_price @price = model.find(params[:id]) end def new_price @price = @event ? model.build : model.new end def get_event @event = event_model.find(params[:event_id]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dcs-eventable-0.0.8 | app/controllers/eventable/prices_controller.rb |