Class: Crm::Amazon::SchemasController
- Inherits:
-
CrmController
- Object
- CrmController
- Crm::Amazon::SchemasController
- Defined in:
- app/controllers/crm/amazon/schemas_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #refresh_schema ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 17 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_entity end end |
#destroy ⇒ Object
34 35 36 37 38 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 34 def destroy @amazon_schema.destroy flash[:info] = 'Schema deleted' redirect_to url_for(action: :index) end |
#index ⇒ Object
3 4 5 6 7 8 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 3 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
13 14 15 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 13 def new @amazon_schema = AmazonSchema.new end |
#refresh_schema ⇒ Object
28 29 30 31 32 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 28 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
10 11 |
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 10 def show end |