I think you are looking for attributes_before_type_cast. See
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001057
Sandeep Gudibanda wrote:> Hi,
>
> I have a select list of this fashion: edit_patient.rhtml
>
> <%= select ''patient'', ''status'',
[[''Unspecified'',1], [''Researhing'',2],
>
[''Critical'',3],
> [''Normal'',4],
> [''Needs extra
person'',5],
> %>
>
> I have enums defined in the database(mysql) for status. Storage is fine.
> But on retrieval, it is always show it as Unspecified . But if i just
> display status , i am getting the right string. I realized this was
> happening , because returned value for status is string and hence
> Selected option is of 0.
>
> Now how do i force the retrieval to numeric context ?
> forcing numeric context like status+0 doesn''t work in rails :(
>
> Any suggestions?
>
> Sandeep G
>
--
Sincerely,
William Pratt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---