can't you just make an instance method to do this?
def full_address
  @full_address ||= '%s %s %s %s %s' % [ self.name, self.addr1,
self.posttown, self.postcode, self.postcode ]
end

then in your view you can just call C.full_address.  I even threw in a
little cache so on multiple calls the string will already be set.

Michael

On Fri, Feb 27, 2009 at 6:00 AM, Worrab <[email protected]> wrote:

>
> ('L' plates still firmly attached)
>
> This is probably dead easy, but I'm utterly stuck - pointers much
> appreciated.
>
> I have an overly simple address model:
>
> class Client
>  include DataMapper::Resource
>
>  property :id, Serial
>
>  property :name, String
>  property :addr1, String
>  property :posttown, String
>  property :postcode, String
>  property :phone, String
>
>  has n, :tickets
> end
>
> All I want to do is put the address as a line on the final form before
> the table showing a list of client's tickets.  I can display the
> individual elements of course but surely I should be able to
> concatenate everything along the lines of:
> FullAddress:=C.name+", "+C.addr1+", "+C.posttown+", "+postcode+",
> "+phone
>
> and then in the view have:
>  =C.FullAddress
> in order to display the full address
>
> And of course the next step would be to miss out the ", " if an
> element was NULL.
>
> Thanks in advance.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" 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/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to