my final year project.

Hallo there, i'm currently doing my final year project and currently
in my final year and 2 more semesters to go in my local university.
my lecturer told me that i can choose a language to build a web app on
my own. since ROR is new to most of us and i read news how easy it is
to use ruby to built apps from various sources. but i'm still
wondering where is a good start to learn ROR. my back ground is that i
did some lessons on php. and my last project of php involves me to
built a system to manage students who lives in the hostel.

in short. my FYP requires me to built a system that can manage a shop
that only sells toilet bowl and sink, plus possible franchise
branching. hahah, this project its so funny that i took the project in
request... but soon know that its not just a small fish that i can
swallow peacefully.

here's what i can imagine so far, my system need to be able to record
new stock and record it like a stock keeper do and register new model
if its so new that this is the companies latest model with a picture.
the management need to set price for the different models that they
got. than if some one buys a few toilet bowl. my system need to be
able to deduct the stock and come out a delivery order for the stock
keeper. the casher need to be able to print an invoice if the buyer
pays by cheque Or print a receipt if buyer pays by cash. and all print
have letter head attached to it page by page.

then heres another part of the system that can check which branch have
stock for a certain model of toilet bowl or give a summery on the
stock on different branches.

i'm given 8 months to complete this project. but i don't think i need
2 months to complete this project so that i have more time fooling my
self on other subjects or do more part time job in mc D to pay my
fees .

1.my question is, can i built this system using ROR? i can imagine
building it using php. but i really want to learn ROR
2.hmm... i was wondering if i print a receipt, if the item list got so
long, my printer will split the page in two, where the header will be
print at the first page and no header on the next page. and the length
of the page is inconsistent if the item list differs.. how do i
overcome this? i can imagine that the company have already have a
header printed on the paper first then set the margin for the printer
to avoid printing on the header. but, i don't think this will amaze my
lecturer.
3.can anyone send me a link where's the best place to read so that i
can learn more about ROR?

1.my question is, can i built this system using ROR? i can imagine
building it using php. but i really want to learn ROR

Remember that RoR is a framework and not a language. Compare it to CodeIgniter, CakePHP, Symphony in the PHP space.

As to your question: yes, RoR can do that. In fact, your whole project description is a class example of an MVC based application. If you have worked with unit and integration tests before in the course of your education, I would recommend using a BDD or TDD approach for your Rails app right away.

2.hmm… i was wondering if i print a receipt, if the item list got so
long, my printer will split the page in two, where the header will be
print at the first page and no header on the next page. and the length
of the page is inconsistent if the item list differs… how do i
overcome this? i can imagine that the company have already have a
header printed on the paper first then set the margin for the printer
to avoid printing on the header. but, i don’t think this will amaze my
lecturer.

Generate a PDF instead. I would recommend PrinceXML, which you can just use in demo mode since it’s just a school project. PrinceXML allows you to generate a PDF from HTML+CSS, including all the cases with headers and footers you correctly indicated as problematic with just an HTML print.

3.can anyone send me a link where’s the best place to read so that i
can learn more about ROR?

http://guides.rubyonrails.org/

http://peepcode.com/products/test-first-development

Just google around, there’s plenty of Rails related resources out there.

Best regards

Peter De Berdt

While I agree with much of what Peter said, I have had extensive
experience with generating .pdf files, including PrinceXML. The
problems which I experienced with PrinceXML were (a) it requires an
"external" step in that you have to generate the .pdf from Prince,
based on a file which you created from your ROR application; and (b)
you have to manually go into the xml file and "escape" things like "&"
signs. Also, Prince requires that you generate a specific .css file
(no big deal, but another step).

After playing with various other .pdf generation techniques, I landed
on the combination of the Prawn gem and the Prawnto plugin, which
allow a seamless integration of your ROR application and .pdf output.
As far as the issue of "headers" at the start of each page, what I do
is to simply start each individual item with a NewPage followed by a
Header partial.

Good luck with your EOY project, and ROR is definitely the way to go.

Sandy

Remember that RoR is a framework and not a language. Compare it to
CodeIgniter, CakePHP, Symphony in the PHP space.

No RoR is a thing to build websites, as pure php, symphony, and pure
ruby do, so it is fair to compare them.

RoR is stuff written in Ruby that avoids writing boiler plate.

Beware 2 months is certainly no enough to get your app going. In real
life, a usable blog takes more than 15 minutes to get built.

Have fun learning and working with Rails.

Fernando Perez wrote:

Remember that RoR is a framework and not a language. Compare it to
CodeIgniter, CakePHP, Symphony in the PHP space.

No RoR is a thing to build websites, as pure php, symphony, and pure
ruby do, so it is fair to compare them.

It's fair to compare Rails and Symfony. It's fair to compare pure PHP
and pure Ruby. That's about it, really.

RoR is stuff written in Ruby that avoids writing boiler plate.

No, it's much more than that, unless you have a very broad definition of
"boilerplate".

Beware 2 months is certainly no enough to get your app going.

Of course it is. The app is very simple, and the OP should be able to
get a usable version within 2 months (depending on how long it takes him
to learn Ruby and Rails, of course).

In real
life, a usable blog takes more than 15 minutes to get built.

Of course. 15 minutes is not 2 months.

Have fun learning and working with Rails.

Best,

While I agree with much of what Peter said, I have had extensive
experience with generating .pdf files, including PrinceXML. The
problems which I experienced with PrinceXML were (a) it requires an
“external” step in that you have to generate the .pdf from Prince,
based on a file which you created from your ROR application;

If you mean you have to pass on a rendered document to the prince command line utility, then yes. Generate a file… no. Whether you use Princely (http://github.com/mbleigh/princely) or the PDF helper (http://sublog.subimage.com/2007/05/29/html-css-to-pdf-using-ruby-on-rails), there is no need to generate a file as such. The content is just passed on to the command line utility right away.

and (b)
you have to manually go into the xml file and “escape” things like “&”
signs. Also, Prince requires that you generate a specific .css file
(no big deal, but another step).

When you’re going from web to print, you’ll always end up with a separate styling file, although that can just be basic stuff like overriding background colors, hiding certain elements, defining page size etc in addition to your normal view stylesheet. About the escaping, I’ve never had that problem, since you will be escaping the HTML in your ERB views anyway (and in Rails 3 it will be done by default). Not using the XML feature, but the HTML -> PDF feature though.

After playing with various other .pdf generation techniques, I landed
on the combination of the Prawn gem and the Prawnto plugin, which
allow a seamless integration of your ROR application and .pdf output.
As far as the issue of “headers” at the start of each page, what I do
is to simply start each individual item with a NewPage followed by a
Header partial.

We also looked into all PDF solutions out there.

We had to provide our customers with the option to generate their own PDF layouts, including vector images in the header etc. So basically what we have in our application is a module where our customers can use something they are familiar with (they’re advertising agencies for the most part), i.e. HTML + CSS, with some Liquid tags sprinkled in, which we then run through the Liquid renderer and pass on to prince, the result is returned to the Rails app right away and streamed to the client, not a single “file” is generated along the way.

Prawn requires you to code the PDF into your app. Whether one likes the syntax is debatable (I for one don’t :-)). It’s also fairly limited in what it can do and there’s tricky involved to achieve some fairly common things, like you mentioned yourself.

That said, Prince, Prawn, wicked_pdf, they are all valid options. It all depends on the requirements of your application.

PrinceXML is by far the most flexible and most feature rich out of the bunch and will give you the smallest PDF, but it comes with a very hefty price tag. Wicked_pdf (which uses wkhtmltopdf) is free, but when we tried it, it was very unstable and still had a long way to go in terms of features. Prawn is nice because it doesn’t use any external applications to render the PDF, but it is very limited compared to the other two imo.

I’d say: complex or large documents, especially if they have vector images, high res images or custom fonts, are a Prince thing. Reports or simple documents (possibly the invoice document the original poster talked about) are more of Prawn’s territory. Wicked_pdf dangles a bit in between those two, would like to hear about people’s experience with it lately.

BTW, I’m not an avid supporter of closed source software, but I have to say YesLogic has excellent support and their product is great.

Best regards

Peter De Berdt

Remember that RoR is a framework and not a language. Compare it to
CodeIgniter, CakePHP, Symphony in the PHP space.

No RoR is a thing to build websites, as pure php, symphony, and pure
ruby do, so it is fair to compare them.

Ruby on Rails is a framework, it even says so on the rubyonrails.org site. It was very fair of me to compare it to PHP frameworks like Symphony, which is basically a very Rails inspired framework for PHP developers.

Ruby is a language, as is PHP. They both can do more than serve or generate web pages.

RoR is stuff written in Ruby that avoids writing boiler plate.

I don’t know what you see as boiler plate, but considering the amount of code in Rails, I would hardly say it’s some helper functions to build websites with database interaction quicker than from scratch. Rails has a very well defined API, using reusable abstractions and programming patterns to achieve a certain featureset, i.e. build web applications, which by definition is a framework.

Beware 2 months is certainly no enough to get your app going. In real
life, a usable blog takes more than 15 minutes to get built.

It doesn’t need to be. Modelwise the project seems to be quite easy, there’s only a few scenarios in there that need to be covered and by the description alone you can clearly see the different iterations for the project.

The most difficult part about this application is plotting out the database structure and relationships and defining the user scenarios, all of which are totally unrelated to Rails and should be fairly trivial for someone in his final year of… something. Translating them into Rails code is just browsing the API and scratching your head every once in a while and let Google help you out.

The dangerous element will be how you will present it to the user and you can go very fancy and get stuck into a very very timeconsuming hell, or you can just make it simple, yet just as powerful. If you have time left, you can then enhance the experience by refactoring some views and sprinkling it with some functional Javascript (i.e. something that enhances the application).

Best regards

Peter De Berdt

Peter De Berdt wrote:
[...]

Prawn requires you to code the PDF into your app.

That is not necessarily true. prawn_format generates PDF files from
HTML. (I've never used it, so I don't know how well it works, but I'm
going to try to switch some PDF views from Prawn code to HTML soon.)

[...]

BTW, I'm not an avid supporter of closed source software, but I have
to say YesLogic has excellent support and their product is great.

I've never heard a bad thing about Prince, other than its price tag.
Good to know about support; I find that very often, the most expensive
software has the worst support.

Best regards

Peter De Berdt

Best,

Psyionx,

1.my question is, can i built this system using ROR? i can imagine building it using php. but i really want to learn ROR

Remember that RoR is a framework and not a language. Compare it to CodeIgniter, CakePHP, Symphony in the PHP space.

As to your question: yes, RoR can do that. In fact, your whole project description is a class example of an MVC based application. If you have worked with unit and integration tests before in the course of your education, I would recommend using a BDD or TDD approach for your Rails app right away.

I would not like to join the battle that has just developed here. But, as far as I know Ruby on Rails is more of a framework than a language. In other words, the phrase “Ruby on Rails” implies the language “Ruby” is running on some infrastructure (=framework), in which case it is Rails.
I am very much exited to hear that you would like to build a system using Ruby on Rails. It is one of the cool frameworks I ever encountered!!
As Peter said, I would recommend you to start using Behavioral Driven Development (BDD) or Test Driven Development (TDD). It is a cool experience to learn the ways of coding as a “tender” stage like yours. (Forgive me if that sounds diminutive). There are good BDD/TDD technologies available for you. Some of them include Cucumber (BDD), RSpec(TDD) and Shoulda (TDD). Get familiar with at least one TDD and/or one BDD technology. This is how I got into RoR. There’s much fun on RoR side of programming, especially when dealing with TDD!!

2.hmm… i was wondering if i print a receipt, if the item list got so long, my printer will split the page in two, where the header will be print at the first page and no header on the next page. and the length of the page is inconsistent if the item list differs… how do i overcome this? i can imagine that the company have already have a header printed on the paper first then set the margin for the printer to avoid printing on the header. but, i don’t think this will amaze my lecturer.

Generate a PDF instead. I would recommend PrinceXML, which you can just use in demo mode since it’s just a school project. PrinceXML allows you to generate a PDF from HTML+CSS, including all the cases with headers and footers you correctly indicated as problematic with just an HTML print.

There are several ways of making this happen. I should admit that, most of the readily available gem solutions have disappointed me. There is one that has done me some justice: the combination of the Prawn gem and the Prawnto plugin. As Sandy describes, Prawn/Prawnto seamlessly integrates of the Rails application and and produces nice PDF documents. You may need Ryan Bates’s railscast on how to generate PDFs using Prawn and Prawnto.

In one project, I played around with HTML, CSS and JavaScript to produce nice PDF reports too. For me, it is one of the simple but powerful hack solutions. There is a blog post you can follow here (Printing HTML Documents Using Customised CSS and JavaScript).

  1. can anyone send me a link where’s the best place to read so that i can learn more about ROR?
    http://guides.rubyonrails.org/
    http://peepcode.com/products/test-first-development

I think http://railscasts.com/episodes/ has nice casts for you.