compact join with new line...

J

Josselin

I would like to compact join address elements by inserting a new line
between them

in my class address I am using

def to_s
[@street, @city, @country ].compact.join(" - ")
end

but I'd like to replace " -" by a new line character to display the
full adress on 3 lines

is it possible ?

joss
 
F

Farrel Lifson

I would like to compact join address elements by inserting a new line
between them

in my class address I am using

def to_s
[@street, @city, @country ].compact.join(" - ")
end

but I'd like to replace " -" by a new line character to display the
full adress on 3 lines

is it possible ?

joss


def to_s
[@street, @city, @country ].compact.join("\n")
end
 
J

Josselin

I would like to compact join address elements by inserting a new line
between them

in my class address I am using

def to_s
[@street, @city, @country ].compact.join(" - ")
end

but I'd like to replace " -" by a new line character to display the
full adress on 3 lines

is it possible ?

joss


def to_s
[@street, @city, @country ].compact.join("\n")
end

thanks .. that's what I did, but I realize that displaying it inside a
Rails view, I should join with a "<br />"
;-))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top