I need to do a if field value = 1 then method but I cannot seem to find the right way /sytax for it. I have a rule table which contains a selector_id field. If set to 1 then do A else do B. No matter what type of syntax I try I cannot seem to get it working. Anyone that can help out? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
NeoWip wrote:> I need to do a if field value = 1 then method but I cannot seem to > find the right way /sytax for it. > > I have a rule table which contains a selector_id field. If set to 1 > then do A else do B. > > No matter what type of syntax I try I cannot seem to get it working. > Anyone that can help out? > > > > > >if (field_value == 1) do stuff else do different stuff end Make sure you use a double = when comparing values. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I still get a NameError in RulesController#learnif
The table name is rules, model name rule and the field is
selector_id.
Here is what I have
if (selector_id == 1)
@rules = ''test''
else
@rules = ''works''
what am I doing wrong?
On 28 apr, 20:45, Jarod Reid
<j...-1hZLCM57iRLR7s880joybQ@public.gmane.org>
wrote:> NeoWip wrote:
> > I need to do a if field value = 1 then method but I cannot seem to
> > find the right way /sytax for it.
>
> > I have a rule table which contains a selector_id field. If set to 1
> > then do A else do B.
>
> > No matter what type of syntax I try I cannot seem to get it working.
> > Anyone that can help out?
>
> if (field_value == 1)
> do stuff
> else
> do different stuff
> end
>
> Make sure you use a double = when comparing values.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
got it
t = Rule.find(1)
if ( t.selector_id == 2)
@rules = ''test''
else
@rules = ''works''
On 28 apr, 21:02, NeoWip <bas....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I still get a NameError in RulesController#learnif
>
> The table name is rules, model name rule and the field is
> selector_id.
>
> Here is what I have
> if (selector_id == 1)
> @rules = ''test''
> else
> @rules = ''works''
>
> what am I doing wrong?
>
> On 28 apr, 20:45, Jarod Reid
<j...-1hZLCM57iRLR7s880joybQ@public.gmane.org> wrote:
>
> > NeoWip wrote:
> > > I need to do a if field value = 1 then method but I cannot seem
to
> > > find the right way /sytax for it.
>
> > > I have a rule table which contains a selector_id field. If set to
1
> > > then do A else do B.
>
> > > No matter what type of syntax I try I cannot seem to get it
working.
> > > Anyone that can help out?
>
> > if (field_value == 1)
> > do stuff
> > else
> > do different stuff
> > end
>
> > Make sure you use a double = when comparing values.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---