Monday 15 February 2010

Ruby on Rails Each... do loop displays the hash -


I'm building an app's management dentists and locations. I have just finished showing the list of all the practitioners in that place and finished adding the code and adding the code. However, when I present the page, it is dumping the entire hash (places. Practitioner.each) above my formatted list. How did I go to hash?

My show.html.erb here

  & lt; P & gt; & Lt; B & gt; Place name: & lt; / B & gt; & Lt;% = @ location.location_name% & gt; & Lt; / P & gt; & Lt; P & gt; & Lt; B & gt; Location ID: & lt; / B & gt; & Lt;% = @ location.id% & gt; & Lt; / P & gt; & Lt; P & gt; & Lt; Strong & gt; Doctors at this place & lt; / Strong> & Lt; / P & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; Th & gt; First name & lt; / Th & gt; & Lt; Th & gt; Last name & lt; / Th & gt; & Lt; Th & gt; Role & lt; / Th & gt; & Lt; Th & gt; Production target & lt; / Th & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; / TR & gt; & Lt;% = @ location Practitioner. Businessman & Gt%; & Lt; TR & gt; & Lt; Td> & Lt;% = Doctor First_name% & gt; & Lt; / Td> & Lt; Td> & Lt;% = practitioner.last_name% & gt; & Lt; / Td> & Lt; Td> & Lt;% = practitioner.role% & gt; & Lt; / Td> & Lt; Td> & Lt;% = Doctor.production_gall% & gt; & Lt; / Td> & Lt; Td> & Lt;% = link_to "edit", edit_practitioner_path (practitioner)%> & Lt; / Td> & Lt; / TR & gt; & Lt;% end% & gt; & Lt; / Table & gt;   

and how this page looks ...

  Location name: Waterview location ID: 1 doctor at this location [# & lt; Business ID: 1, first_name: "Dr. Robert", last_name: "angux", role: "dentist", production_gown: 10000, location_id: 1, created_t: "2013-03-26 17:34:38", updated_t : "2013-03 -26 21:52:37" & gt;, # & lt; Business ID: 3, first_name: "mementa", last_name: "hickleberry", role: "hajinist", production_gown: 4800, location_id: 1, created_t: "2013- 03-26 21:49:46", updated_at: "2013 -03-26 21:49:46 "& gt;, # & lt; Business ID: 4, first_name: "Dr. Sandra", last_name: "Pager", role: "dentist", production_gown: 22000, location_id: 1, created_t: "2013-03-26 22:05:38", updated_t: "2013-03-26 22:05:38" & gt;] First Name Last Name Role Production Target ** Dr. Robert Anjoy Dentist 10000 Edit Smantha Hickleberry Hygenist 4800 edit Dr. Sandra preser dentist 22000 edit   

What am I doing wrong? I just have a table list ...

Dennis

this line is yours problem. You are using the "=" symbol that displays the output of the Ruby statement:

  & lt;% = @ location.practitioner.each do | Businessman & Gt%;   

Change it to:

  & lt;% @ location.practitioner.each do | Businessman & Gt%;    

No comments:

Post a Comment