Class: Crm::Amazon::SchemasController

Inherits:
CrmController
  • Object
show all
Defined in:
app/controllers/crm/amazon/schemas_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#indexObject



3
4
5
6
7
8
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 3

def index
  authorize! :manage, AmazonSchema
  @q = AmazonSchema.ransack(params[:q])
  @q.sorts = 'product_type asc' if @q.sorts.empty?
  @pagy, @amazon_schemas = pagy(@q.result)
end

#newObject



13
14
15
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 13

def new
  @amazon_schema = AmazonSchema.new
end

#refresh_schemaObject



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

#showObject



10
11
# File 'app/controllers/crm/amazon/schemas_controller.rb', line 10

def show
end