[Rails] how to access an element from a instance variable
Folks im new to rails and was wondering how i would access these
elements from my view
in my controller i have
@data = Editpatient.find(:all, :conditions => ["patient_id = ?",
params[:patients]] )
and in the view i have <%= @data %>
this displays all the data but i only want one field. This is what is
displayed.
[#<Editpatient id: 27, patient_id: 14, provider_id: 11, weight_gained:
123, weight_lost: nil, created_at: "2011-11-26 21:07:13", updated_at:
"2011-11-26 21:07:13", patient_name: nil, provider_name: nil>]
the only field i want is patient_id
ive tried this in the view @data[:patient_id] and i get
can't convert Symbol into Integer
any help is appreciated thanks
--
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@googlegroups.com.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home