I'm doing a small toy app to learn rails, and I ran into some difficulty
with one of my views, specifically with the parameters hash that is
returned to me during the create action
Currently, given the form I have now, I get the following two hashes to
appear among my parameters.
"claim"=>{"date_filed"=>"04/06/2008",
"doctor_number"=>"D53475",
"procedure_code"=>"51551",
"date_performed"=>"04/03/2008"},
"patient_query"=>{"patient"=>{"patient_number"=>"F23793"}}}
Ideally, I'd like my parameters to be
"claim"=>{"date_filed"=>"04/06/2008",
"doctor_number"=>"D53475",
"procedure_code"=>"51551",
"date_performed"=>"04/03/2008"},
"patient_query"=>{"patient_number"=>"F23793"}}
or cleanest of all would be
"claim"=>{"date_filed"=>"04/06/2008",
"doctor_number"=>"D53475",
"procedure_code"=>"51551",
"date_performed"=>"04/03/2008"},
"patient_number"=>"F23793"
Here's the view code I have now for new.html.erb
1. <h1>Enter new claim data</h1>
2. <%= error_messages_for :claim %>
3.
4. <% form_for :claim, :url => claims_path do |f| %>
5. <p>
6. Patient Number:
7. <%= text_field :patient_query, :patient_number, :index =>
:patient %>
8. </p>
9. <p>
10. Doctor Number:
11. <%= f.text_field :doctor_number %>
12. </p>
13. <p>
14. Procedure Code:
15. <%= f.text_field :procedure_code %>
16. </p>
17. <p>
18. Date Performed:
19. <%= f.text_field :date_performed %>
20. </p>
21. <p>
22. Doctor Filed:
23. <%= f.text_field :date_filed %>
24. </p>
25. <%= submit_tag "Create Claim" %>
26. <% end %>
27. <%= link_to "Or go back to all claims.",
28. doctors_path %>
My motivation for doing things this way is that I have a patient model
and a claim model and a patient has many claims. Each patient has a
unique identifier (different from the standard id), and I am going to
search the database for the patient with this patient_number and set the
claim's pateint_id attribute to the id number of the found patient.
So patient_number is an attribute of the patient that owns the claim,
not an attribute of the claim itself.
Any help would be appreciated.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---