I can not get create response for current_patient. Getting response 401 unauthorized. I have tried updating the ability file.
responses_controller.rb:
def create
@reply = Response.create(params[:response])
office = ""
if current_user
office = current_user.office || current_user.account.offices.first
elsif current_patient
office = current_patient.office_id
end
...........
end
Ability file:
def patient
can :create, Response, :patient_id => @patient.id
end
Response:
Started POST "/responses" for 127.0.0.1 at 2014-11-20 17:35:45 -0500
Processing by ResponsesController#create as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"blah_blah_blah", "response"=>{"review_id"=>"", "date"=>"2014-11-20 17:35:40 -0500", "patient_id"=>"13", "message"=>"Howdy neighbor!"}, "commit"=>"Submit Reply"}
Completed 401 Unauthorized in 166ms