In my lib/tasks/populate.rake file I have to write some hard coded data in proper html format with proper alignment. How can I write it in the populate file? Is there any way to parse the HTML tags after writing?For random data I know there is populator gem. But I want some hard coded data. Please some help me out.
Asked
Active
Viewed 274 times
2 Answers
0
First write html data inside html file then align and validate file. If everything is write then copy html data inside file to lib/tasks/populate.rake
file. There are many online tools that can do validation. http://validator.w3.org/

Sandip Ransing
- 7,583
- 4
- 37
- 48
-
1. Payment Mode: Direct Payment or Telegraphic Transfer to: A/c Name: xyz Technologies Pvt. Ltd. A/c No.: 4343431 A/c Type: Current Account Bank & Branch: xyz Bank Ltd., RTGS/NEFT IFSC Code: dfdgf SWIFT Code: ICdfg 2. PAN No.: Adgf 3. Ser. Tax. Code No.: AABCI2464GST001 – Sneha Kachroo Aug 14 '12 at 07:07
-
This is my data. How can I align it properly? – Sneha Kachroo Aug 14 '12 at 07:08
-
make use of html table to align data properly – Sandip Ransing Aug 14 '12 at 07:46
-
Actually I mean to say that can I wite html tags in populate.rake file – Sneha Kachroo Aug 14 '12 at 08:36
0
You need to use Ruby heredoc syntax to align your code
text = <<END
<p>Whatever you want to write in whatever form</p>
line with spaces in front
Another indented line
Account No. : XYZ
END
text = text.html_safe
There should be no spaces before the closing END
.

Kulbir Saini
- 3,926
- 1
- 26
- 34
-
-
-
-
When I do rake db:drop I get this error: rake aborted! /home/icicle/work/code/invoiced/lib/tasks/populate.rake:274: can't find string "END" anywhere before EOF /home/icicle/work/code/invoiced/lib/tasks/populate.rake:104: syntax error, unexpected $end, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END – Sneha Kachroo Aug 14 '12 at 09:05