On Sat, Nov 26, 2011 at 3:00 PM, brent brent <li...@ruby-forum.com> wrote:

> @data = Editpatient.find(:all, :conditions => ["patient_id = ?",
> params[:patients]] )

erm, well. If you expect to get back one record for a given patient_id
it could be more readably expressed as:

@editpatient = Editpatient.find_by_patient_id(params[:patient_id])

(assuming you fix your form to pass 'patient_id').

> and in the view i have <%= @data %>

Which is opaquely named, and hides the fact that you're fetching
an array.

> this displays all the data but i only want one field. This is what is
> displayed.

  @data.first.patient_id

would do it, but I'd strongly recommend cleaning up the code to make
your intent more apparent, and only fetch one record, e.g.

  @editpatient.patient_id

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to