Sha256: 92f25abae6758e6479d7d3b5427185fb9626ac3d42240a464ead02f560ebc39e

Contents?: true

Size: 1.7 KB

Versions: 12

Compression:

Stored size: 1.7 KB

Contents

module Auth::Concerns::Shopping::ProductControllerConcern

  extend ActiveSupport::Concern

  included do
    
    include Auth::Shopping::Products::ProductsHelper

  end

  def initialize_vars
  	instantiate_shopping_classes
    @auth_shopping_product_params = permitted_params.fetch(:product,{})
    @auth_shopping_product = params[:id] ? @auth_shopping_product_class.find_self(params[:id],current_signed_in_resource) : @auth_shopping_product_class.new(@auth_shopping_product_params)
  end

  

  def create
    check_for_create(@auth_shopping_product)
    @auth_shopping_product = add_owner_and_signed_in_resource(@auth_shopping_product,{:owner_is_current_resource => true})
  	
    @auth_shopping_product.save
    respond_with @auth_shopping_product
    
  end

  def update
    check_for_update(@auth_shopping_product)
    @auth_shopping_product = add_owner_and_signed_in_resource(@auth_shopping_product,{:owner_is_current_resource => true})
    @auth_shopping_product.assign_attributes(@auth_shopping_product_params)
    @auth_shopping_product.save
    respond_with @auth_shopping_product
    
  end

  def index
    instantiate_shopping_classes
    @auth_shopping_products = @auth_shopping_product_class.all
  end

  def show
    instantiate_shopping_classes
    @auth_shopping_product = @auth_shopping_product_class.find(params[:id])
    ## will render show.json.erb if its a json request.
  end

  def destroy
    check_for_destroy(@auth_shopping_product)
    @auth_shopping_product.delete
    respond_with @auth_shopping_product
  end

  def new
    
  end

  def edit

  end

  def permitted_params
  	params.permit({:product => [:name,:price]})
  end

end

## how to handle situation where the resource_id and resource_class is 

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
wordjelly-auth-1.1.0 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-1.0.9 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-1.0.8 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-1.0.5 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-1.0.4 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-1.0.3 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-1.0.2 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-0.0.8 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-0.0.5 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-0.0.4 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-0.0.3 app/controllers/auth/concerns/shopping/product_controller_concern.rb
wordjelly-auth-0.0.1 app/controllers/auth/concerns/shopping/product_controller_concern.rb