On Sun, Sep 6, 2009 at 3:33 PM, Hugues
Brunelle<[email protected]> wrote:
> I did :
> <% for service in @project.services %-><%= service.name_fr.downcase -%>,
> <% end -%>.
>
> The problem is with the listing itself, it puts this :
> {Project.name} required {service.name1}, {service.name2},
> {service.name3},.
>
> There is a problem with the last comma. It looks awful from a web
> developer view.
>
> I would like :
> {Project.name} required {service.name1}, {service.name2} and
> {service.name3}.
Something like this should work:
@project.services.collect {|service| service.name}.join(", ").gsub(/,
([A-Za-z]+)$/,' and \1.')
:: though you might need to tweak that regex, depending on what's
in a service name...
HTH,
--
Hassan Schroeder ------------------------ [email protected]
twitter: @hassan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---