我无法获得current_patient的创建响应。获得响应401未授权。我已经尝试更新能力文件。
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
能力档案:
def patient
can :create, Response, :patient_id => @patient.id
end
响应:
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