diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-17 12:05:14 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-17 12:05:14 +0100 |
commit | eaad37485fe59d0306c37cc038dda6d210052910 (patch) | |
tree | 072c4b0e33d442528555b82c415f5e7a1712b2b0 /app/controllers/phone_models_controller.rb | |
parent | 3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff) | |
parent | b80bd744ad873f6fc43018bc4bfb90677de167bd (diff) |
Merge branch 'develop'
Diffstat (limited to 'app/controllers/phone_models_controller.rb')
-rw-r--r-- | app/controllers/phone_models_controller.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/app/controllers/phone_models_controller.rb b/app/controllers/phone_models_controller.rb new file mode 100644 index 0000000..59facdf --- /dev/null +++ b/app/controllers/phone_models_controller.rb @@ -0,0 +1,52 @@ +class PhoneModelsController < ApplicationController + load_and_authorize_resource :manufacturer + load_and_authorize_resource :phone_model, :through => [:manufacturer] + + before_filter :spread_breadcrumbs + + def index + end + + def show + end + + def new + @phone_model = @manufacturer.phone_models.build + end + + def create + @phone_model = @manufacturer.phone_models.build.new(params[:phone_model]) + if @phone_model.save + redirect_to manufacturer_phone_model_path( @manufacturer, @phone_model ), :notice => t('phone_models.controller.successfuly_created') + else + render :new + end + end + + def edit + end + + def update + if @phone_model.update_attributes(params[:phone_model]) + redirect_to manufacturer_phone_model_path( @manufacturer, @phone_model ), :notice => t('phone_models.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @phone_model.destroy + redirect_to manufacturer_phone_models_url( @manufacturer ), :notice => t('phone_models.controller.successfuly_destroyed') + end + + private + + def spread_breadcrumbs + add_breadcrumb t("manufacturers.index.page_title"), manufacturers_path + add_breadcrumb @manufacturer, manufacturer_path(@manufacturer) + add_breadcrumb t("phone_models.index.page_title"), manufacturer_phone_models_path(@manufacturer) + if @phone_model && !@phone_model.new_record? + add_breadcrumb @phone_model, manufacturer_phone_model_path(@manufacturer, @phone_model) + end + end +end |