Module: Auth::Concerns::Shopping::ProductControllerConcern
- Extended by:
- ActiveSupport::Concern
- Included in:
- Shopping::ProductsController
- Defined in:
- app/controllers/auth/concerns/shopping/product_controller_concern.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #initialize_vars ⇒ Object
- #new ⇒ Object
- #permitted_params ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 19 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 |
#destroy ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 48 def destroy check_for_destroy(@auth_shopping_product) @auth_shopping_product.delete respond_with @auth_shopping_product end |
#edit ⇒ Object
58 59 60 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 58 def edit end |
#index ⇒ Object
37 38 39 40 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 37 def index instantiate_shopping_classes @auth_shopping_products = @auth_shopping_product_class.all end |
#initialize_vars ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 11 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 |
#new ⇒ Object
54 55 56 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 54 def new end |
#permitted_params ⇒ Object
62 63 64 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 62 def permitted_params params.permit({:product => [:name,:price]}) end |
#show ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 42 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 |
#update ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/auth/concerns/shopping/product_controller_concern.rb', line 28 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 |