Max Baroi
2008-Sep-28 05:39 UTC
Having trouble writing the right view to generate the desire
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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Sep-28 09:32 UTC
Re: Having trouble writing the right view to generate the desire
On Sep 28, 6:39 am, Max Baroi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> So patient_number is an attribute of the patient that owns the claim, > not an attribute of the claim itself.I think it''s your use of the :index option that is giving you the current output instead of the second variant. For the third variant, just use text_field_tag. Fred> Any help would be appreciated. > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Max Baroi
2008-Sep-28 16:53 UTC
Re: Having trouble writing the right view to generate the de
Both suggestions did exactly what you said. Thank you. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Max Baroi
2008-Sep-29 01:25 UTC
Re: Having trouble writing the right view to generate the de
Now of course I''m having trouble with the default fields in edit. I''ve changed edit.html.erb so that editing an existing claim works. Here''s my edit.html.erb <h1>Edit Claim''s Information</h1> <%= "Enter claim number #{h(@claim.claim_number)}''s information." %> <% form_for :claim, :url => claim_path(params[:id]), :html => {:method => :put} do |f| %> <p> Patient Number: <%= text_field_tag :patient_number %> </p> <p> Doctor Number: <%= text_field_tag :doctor_number %> </p> <p> Procedure Code: <%= f.text_field :procedure_code %> </p> <p> Date Performed: <%= f.text_field :date_performed %> </p> <p> Doctor Filed: <%= f.text_field :date_filed %> </p> <%= submit_tag "Save Changes" %> <% end %> <%= link_to "Or go back to claim information.", claim_path(:id => @claim.id) %> Is there some way to manually set what the default text is in a text field? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---