Class: Crm::Amazon::SchemasController
- Inherits:
-
CrmController
- Object
- CrmController
- Crm::Amazon::SchemasController
- Defined in:
- app/controllers/crm/amazon/schemas_controller.rb
Overview
Controller: schemas.
Instance Method Summary collapse
-
#create ⇒ void
POST /crm/amazon/schemas — creates a schema (defaulted to
must_refresh). -
#destroy ⇒ void
DELETE /crm/amazon/schemas/:id — destroys a schema.
-
#index ⇒ void
GET /crm/amazon/schemas — sortable, paginated list.
-
#new ⇒ void
GET /crm/amazon/schemas/new — blank schema form.
-
#refresh_schema ⇒ void
POST /crm/amazon/schemas/:id/refresh_schema — re-pulls the schema from Amazon.
-
#show ⇒ void
GET /crm/amazon/schemas/:id — a single Amazon schema.
Instance Method Details
#create ⇒ void
This method returns an undefined value.
POST /crm/amazon/schemas — creates a schema (defaulted to must_refresh).
30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 30 def create @amazon_schema = AmazonSchema.new(params[:amazon_schema]) @amazon_schema.schema = { status: :must_refresh } # This is a default value if @amazon_schema.save flash[:info] = 'Schema created, now refresh to pull schema' redirect_to url_for(action: :show, id: @amazon_schema.id) else render :new, status: :unprocessable_content end end |
#destroy ⇒ void
This method returns an undefined value.
DELETE /crm/amazon/schemas/:id — destroys a schema.
53 54 55 56 57 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 53 def destroy @amazon_schema.destroy flash[:info] = 'Schema deleted' redirect_to url_for(action: :index) end |
#index ⇒ void
This method returns an undefined value.
GET /crm/amazon/schemas — sortable, paginated list.
8 9 10 11 12 13 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 8 def index :manage, AmazonSchema @q = AmazonSchema.ransack(params[:q]) @q.sorts = 'product_type asc' if @q.sorts.empty? @pagy, @amazon_schemas = pagy(@q.result) end |
#new ⇒ void
This method returns an undefined value.
GET /crm/amazon/schemas/new — blank schema form.
23 24 25 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 23 def new @amazon_schema = AmazonSchema.new end |
#refresh_schema ⇒ void
This method returns an undefined value.
POST /crm/amazon/schemas/:id/refresh_schema — re-pulls the schema from Amazon.
44 45 46 47 48 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 44 def refresh_schema res = @amazon_schema.refresh_schema flash[:info] = res ? 'Schema refreshed' : 'Failed to refresh schema' redirect_to url_for(action: :show, id: @amazon_schema.id) end |
#show ⇒ void
This method returns an undefined value.
GET /crm/amazon/schemas/:id — a single Amazon schema.
18 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 18 def show; end |