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 ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #refresh_schema ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 18 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 ⇒ Object
35 36 37 38 39 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 35 def destroy @amazon_schema.destroy flash[:info] = 'Schema deleted' redirect_to url_for(action: :index) end |
#index ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 5 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 ⇒ Object
14 15 16 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 14 def new @amazon_schema = AmazonSchema.new end |
#refresh_schema ⇒ Object
29 30 31 32 33 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 29 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 ⇒ Object
12 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 12 def show; end |