Sha256: e04d20e80f41e7cdcb128bca6cdd44a3ea8ba9e715aa1560651da82864dd4d6f

Contents?: true

Size: 962 Bytes

Versions: 4

Compression:

Stored size: 962 Bytes

Contents

module Spree
  module Admin
    class PrototypesController < ResourceController
      after_filter :set_habtm_associations, :only => [:create, :update]

      def show
        if request.xhr?
          render :layout => false
        else
          redirect_to admin_prototypes_path
        end
      end

      def available
        @prototypes = Prototype.order('name asc')
        respond_with(@prototypes) do |format|
          format.html { render :layout => !request.xhr? }
          format.js
        end
      end

      def select
        @prototype ||= Prototype.find(params[:id])
        @prototype_properties = @prototype.properties

        respond_with(@prototypes)
      end

      private

        def set_habtm_associations
          @prototype.property_ids = params[:property].blank? ? [] : params[:property][:id]
          @prototype.option_type_ids = params[:option_type].blank? ? [] : params[:option_type][:id]
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spree_core-1.2.5 app/controllers/spree/admin/prototypes_controller.rb
spree_core-1.2.4 app/controllers/spree/admin/prototypes_controller.rb
spree_core-1.2.3 app/controllers/spree/admin/prototypes_controller.rb
spree_core-1.2.2 app/controllers/spree/admin/prototypes_controller.rb