user.presence || ""

see http://rubydoc.info/docs/rails/3.0.0/Object:presence

On Fri, Sep 10, 2010 at 10:25 AM, Mauro <[email protected]> wrote:

> If you know grails, there is a feature like this: <% user.name? %>
> that prevents to chek if the value is null or not.
> In rails view I have to do
> <% if user.name %>
>  <%= user.name %>
> <% end %>
> to display user.name if it is not nil.
> There is a shortcut or some feature like that in grails?
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to