All right, I've done more testing with attr_accessor
:site_id. My
latest finding is that site_id IS returned upon an error in
the
validation, BUT the site select doesn't restore the
selection. I have
my site select defined as follows:
<%= select(:equipment, :site_id,
Site.list(session[:customer_id]),
{ :include_blank => 'true' }) %>
I have no idea how the selection is not maintained if
equipment.site_id does contain the value that I submitted.
Also, I forgot to mention that I WOULD like to have site_id
as a model
method for equipment. I have it defined as:
def site_id
if self.building
return self.building.site.id
else
nil
end
end
So, instead of attr_acessor :site_id, I decided to go with
attr_writer :site_id. But here's the interesting part, if I
do it that
way, I don't get the site_id back upon an error. But I do
get it back
when I use attr_accessor. I don't understand it at all.
Any ideas? This is not such a big deal, but I'm very curious
how to do
it elegantly.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|