Thanks for all the replies. It then works just as I had thought but
I'm not getting the results that I expect so I need to look a bit
further. But I now know that I am using the method correctly. Thanks
once again,

On 18 May 2010 19:33, Michael Pavling <pavl...@gmail.com> wrote:
> On 18 May 2010 07:41, Paul Jonathan Thompson <rails...@gmail.com> wrote:
>> Mapper.exists?(product.id)
>>
>> How do I test if the condition returned was true or false?
>
> Most simply, you would use "if"... either by wrapping a conditional
> block around code to run if the condition is met, or with a "guard"
> clause. If the condition evaluates as true, then the code inside the
> block (or being guarded) with run :
>
>  if Mapper.exists?(product.id)
>   �...@mapper = Mapper.find(product.id)
>  end
>
>  or
>   �...@mapper = Mapper.find(product.id) if Mapper.exists?(product.id)
>
> But there's plenty of other ways of logically checking conditions:
>  "unless" is equivalent to "if !"
>  Ternary operators are useful
>  "case" statements have their place.
>  "||=" is a lovely little Ruby idiom for checking for nil values.
>
> If you Google for "ruby conditional logic" you'll find lots of
> beginners guides covering this material.
>
> --
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to