Forum: Ruby on Rails Trying to format a phone number in PDF::Writer

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9cb4de6b61b568a8c13d866ccf3b3433?d=identicon&s=25 Dan Poynor (Guest)
on 2007-01-08 22:27
I'm still learning and can't figure out how to get a phone number out of
my database and into a pdf document with some standard rails formatting.

Specifically, in my controller my "define pdf" method includes:

clientphone = "1234567890"
pdf.text number_to_phone(clientphone)

which generates an error reading
undefined method `number_to_phone'

I also tried

pdf.text ActionView.number_to_phone(clientphone)

which generates the same error.

I'm not trying to use a template handler or anything tricky. I create a
separate rails application to just output that one string formated as a
phone number and it has the same error.

Any help appreciated.

9cb4de6b61b568a8c13d866ccf3b3433?d=identicon&s=25 Dan Poynor (Guest)
on 2007-01-09 01:15
I believe I've determined that ActionView method can't go in the
controller method. Calling number_to_phone even without using pdf writer
creates an error which kind of makes since. No data manipulation can
take place in the controller.

Now I'm wondering about how to get the number_to_phone result returned
to the controller method for output to the pdf file.

I've been moving my code around so is in a helper but
then the send_data command which renders the file creates errors I think
because it needs to be strickly in the controller.

If I simply move the send_data command out of the helper and back into
the controller it needs to receive the returned data to output.

Without rendering a view, is returing a result from a helper method to a
controller for output suppose to be even possible?
This topic is locked and can not be replied to.