Class: PassTypesController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- PassTypesController
- Defined in:
- app/controllers/pass_types_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/pass_types_controller.rb', line 22 def create @pass_type = PassType.new(params[:pass_type]) @pass_type.organization = current_organization unless @pass_type.save flash[:error] = @pass_type.errors..to_sentence render "new" and return end redirect_to pass_types_path end |
#destroy ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/pass_types_controller.rb', line 36 def destroy @pass_type = current_user.current_organization.pass_types.where(:id => params[:id]).first if @pass_type.destroyable? @pass_type.destroy flash[:notice] = "We've deleted this pass type" else flash[:error] = "Can't delete this pass type because you've sold some passes for this type." end redirect_to pass_types_path end |
#edit ⇒ Object
32 33 34 |
# File 'app/controllers/pass_types_controller.rb', line 32 def edit @pass_type = current_user.current_organization.pass_types.where(:id => params[:id]).first end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/pass_types_controller.rb', line 4 def index @pass_types = current_organization.pass_types.includes(:passes).paginate(:page => params[:page], :per_page => 50) respond_to do |format| format.html format.csv do @filename = 'pass_types.csv' @csv_string = @pass_types.to_comma send_data @csv_string, :filename => @filename, :type => 'text/csv', :disposition => 'attachment' end end end |
#new ⇒ Object
18 19 20 |
# File 'app/controllers/pass_types_controller.rb', line 18 def new @pass_type = PassType.new end |
#update ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/pass_types_controller.rb', line 47 def update @pass_type = PassType.find(params[:id]) @pass_type.update_attributes(params[:pass_type]) flash[:notice] = "Your changes have been saved" redirect_to pass_types_path end |