On 9/27/07, Daniel Talsky
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> This is the code I''m trying to get to work:
>
> validates_inclusion_of :status,
> :in => poll_statuses().keys
>
> def poll_statuses
> return {
> "closed" => "Closed",
> "open" => "Open"
> }
> end
>
> It says there''s no poll_statuses method in Poll. How do I access
this
> method? I''ve tried Poll.poll_statuses().keys, I''ve tried
defining the
> method above the validation. What am I missing here?
You''re correct about moving the method definition above the
validation. That''s necessary.
The other problem is that you''ve defined poll_statuses as an
*instance* method, but you''re calling it as a *class* method. You need
to define it as:
def self.poll_statuses
...
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---