Module: Auth::Concerns::Work::InstructionControllerConcern

Extended by:
ActiveSupport::Concern
Included in:
Work::InstructionsController
Defined in:
app/controllers/auth/concerns/work/instruction_controller_concern.rb

Instance Method Summary collapse

Instance Method Details

#createObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 43

def create
  check_for_create(@auth_work_instruction)
  @auth_shopping_product.instructions << @auth_work_instruction
  @auth_shopping_product.save
  respond_to do |format|
      format.json do 
        render json: @auth_work_instruction.to_json
      end
      format.html do 
        render :partial => "show.html.erb", locals: {instruction: @auth_work_instruction, product: @auth_shopping_product}
      end
  end
end

#destroyObject



82
83
84
85
86
87
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 82

def destroy
  check_for_destroy(@auth_work_instruction)
  @auth_shopping_product.delete_at(get_index)
  @auth_shopping_product.save
  respond_with @auth_work_instruction
end

#editObject



93
94
95
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 93

def edit

end

#get_indexObject



33
34
35
36
37
38
39
40
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 33

def get_index
  index = 0
  @auth_shopping_product.instructions.each do |ins|
    break if ins.id.to_s == @auth_work_instruction.id.to_s
    index+=1
  end
  index
end

#indexObject



72
73
74
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 72

def index

end

#initialize_varsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 9

def initialize_vars
  instantiate_work_classes
  not_found("no product id provided") unless params[:product_id]
 
  @auth_work_instruction_params = permitted_params.fetch(:instruction,{})
  begin
    if @auth_shopping_product = @auth_shopping_product_class.find(params[:product_id])
  
      @auth_shopping_product = @auth_shopping_product_class.find_self(params[:product_id],current_signed_in_resource)
      ## if the instruction id is provided, then it has to exist
      if params[:id]
        @auth_work_instruction = @auth_shopping_product.instructions.select{|c|
          c.id.to_s == params[:id]
        }[0]
      else
        @auth_work_instruction = @auth_work_instruction_class.new(@auth_work_instruction_params)
      end
    end
  rescue Mongoid::Errors::DocumentNotFound
     @auth_shopping_product = @auth_shopping_product_class.new
  end

end

#newObject



89
90
91
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 89

def new
  
end

#permitted_paramsObject

okay so how to port this to the pathofast side ? we can just package the gem and see how it fares. that’s the best way the only remaining major issue will be the images and the only thing that has failed completely is the micro let me first build the create ?



104
105
106
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 104

def permitted_params
	pr = params.permit({:instruction => [:title,:description]}, :id, :product_id)
end

#showObject



76
77
78
79
80
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 76

def show
  instantiate_work_classes
  @auth_shopping_product = @auth_shopping_product_class.find(params[:product_id])
  @auth_work_instruction = @auth_shopping_product.instructions.select{|c| c.id.to_s == params[:id]}[0]
end

#updateObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/auth/concerns/work/instruction_controller_concern.rb', line 57

def update
  check_for_update(@auth_work_instruction)
  @auth_work_instruction.assign_attributes(@auth_work_instruction_params)
  @auth_shopping_product.instructions[get_index] = @auth_work_instruction
  @auth_shopping_product.save
  respond_to do |format|
      format.json do 
        render json: @auth_work_instruction.to_json
      end
      format.html do 
        render :partial => "show.html.erb", locals: {instruction: @auth_work_instruction, product: @auth_shopping_product}
      end
  end
end