Class: RecordsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/records_controller.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) create



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/records_controller.rb', line 6

def create
  task = Task.find params[:task_id]
  if task.prototype.mockup_ids.include?(params[:mockup_id].to_i) && task.test.id == params[:test_id].to_i
    @record.prototype_id = task.prototype.id
    @record.project_id = task.project.id
    @record.user_id = current_user.id
    @record.events = params[:events]
    @record.save
    render json: @record, status: :created
  else
    render json: { errors: 'Wrong attributes!' }, status: :unprocessable_entity
  end
end

- (Object) create_params



20
21
22
# File 'app/controllers/records_controller.rb', line 20

def create_params
  params.permit(:test_id, :task_id, :task_run_id, :mockup_id, :events)
end