Web Application from Scratch - like PHP

Hi,

I come from a PHP background. I've created many web apps in PHP, using
simple self-made ORM classes and also other popular open-source
frameworks.

I intend to learn Ruby thoroughly before jumping to any Ruby web
framework. How do I create simple web applications using plain Ruby (and
a server like WEBrick of course)? I learnt PHP by creating simple
classes that could read stuff from and add to the database. Once I was
through with this, I started learning other major frameworks in PHP
(like Yii). I think it will be best to learn Ruby the same way, once I
know the basic concepts of it.

How do I go about this? How can I create a very simple web app in Ruby,
with a few classes that can talk to the db?

···

--
Posted via http://www.ruby-forum.com/.

http://rack.rubyforge.org/

This was an interesting thread on this subject (begin Jan 2012):

  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/391927

Press the green "N" button on top to follow the discussion.

HTH,

Peter

···

On Tue, Jan 24, 2012 at 7:35 AM, Gaurav C. <chande.gaurav@gmail.com> wrote:

Hi,

I come from a PHP background. I've created many web apps in PHP, using
simple self-made ORM classes and also other popular open-source
frameworks.

I intend to learn Ruby thoroughly before jumping to any Ruby web
framework. How do I create simple web applications using plain Ruby (and
a server like WEBrick of course)? I learnt PHP by creating simple
classes that could read stuff from and add to the database. Once I was
through with this, I started learning other major frameworks in PHP
(like Yii). I think it will be best to learn Ruby the same way, once I
know the basic concepts of it.

How do I go about this? How can I create a very simple web app in Ruby,
with a few classes that can talk to the db?

Your timing is perfect. Satish Talim, of the Ruby Learning Blog, will
soon be starting a free online course on "Programming for the Web with
Ruby". See rubylearning.com/blog/2012/01/21/free-online-course-programming-for-the-web-with-ruby/
for details.

-Dave

···

On Tue, Jan 24, 2012 at 01:35, Gaurav C. <chande.gaurav@gmail.com> wrote:

How do I create simple web applications using plain Ruby (and
a server like WEBrick of course)?

--
Dave Aronson, Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote); details @ http://www.DaveAronson.com/\.

I intend to learn Ruby thoroughly before jumping to any Ruby web
framework. How do I create simple web applications using plain Ruby (and
a server like WEBrick of course)?

If Rack is too hardcore for you, try Sinatra. Here's the code for
Sinatra's Hello World app:

  require "sinatra"

  get "/hello" do
    "<h1>Hello!</h1>"
  end

Stick that in "hello.rb" and run "ruby hello.rb" and visit
http://localhost:4567/hello to see it in action. And it's easy to
deploy a Sinatra app to Heroku too.

It has support for a fair number of web features like HTML templates
and status codes and such and plenty of docs at
http://www.sinatrarb.com/

Sinatra doesn't do databases on its own, but there's nothing stopping
you from using ActiveRecord or DataMapper or Sequel or even DBI [1] to
access a relational DB inside your requests.

[1] http://ruby-dbi.rubyforge.org/

I intend to learn Ruby thoroughly before jumping to any Ruby web
framework.

I applaud your decision! Too many people learn Ruby as an afterthought
to Rails, and pick up lots of misconceptions and bad habits as a
result.

If you need some pointers to online Ruby tutorials, let me recommend:

  http://testfirst.org/ and http://testfirst.org/learn_ruby
  http://rubykoans.com/
  http://rubymonk.com/
  http://pine.fm/LearnToProgram/

- A

···

--
Alex Chaffee - alex@stinky.com
http://alexchaffee.com
http://twitter.com/alexch

You might want to look at Ruby's CGI library, and possibly do some
reading about eruby (hint: eruby is more of a concept than a singular
thing, with multiple implementations). CGI provides a lot of markup
related functionality (generating DTDs and markup, handling POST
requests, et cetera), while eruby provides templating similar in many
ways to what is the norm for PHP web development.

For database connectivity without using big frameworks like Rails (or
even small frameworks like Sinatra, which might be a good stepping stone
between the Ruby basics and Rails as well as being useful in its own
right as a good framework), look into things like the pg (aka ruby-pg),
sqlite, and sequel libraries.

This is, of course, far from comprehensive. It's just suggestions for
where to start looking. Armed with some useful terms like these, Google
can be your friend in making early progress. Good luck.

···

On Tue, Jan 24, 2012 at 03:35:35PM +0900, Gaurav C. wrote:

Hi,

I come from a PHP background. I've created many web apps in PHP, using
simple self-made ORM classes and also other popular open-source
frameworks.

I intend to learn Ruby thoroughly before jumping to any Ruby web
framework. How do I create simple web applications using plain Ruby (and
a server like WEBrick of course)? I learnt PHP by creating simple
classes that could read stuff from and add to the database. Once I was
through with this, I started learning other major frameworks in PHP
(like Yii). I think it will be best to learn Ruby the same way, once I
know the basic concepts of it.

How do I go about this? How can I create a very simple web app in Ruby,
with a few classes that can talk to the db?

--
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]

Rack 2.0 is being undertaken, and it's a huuuuge shift.

With or without documentation? :wink:

···

--
Posted via http://www.ruby-forum.com/\.

Ewww, the rack website could really use some help :wink:

It doesn't even have the latest releases or docs on it!

···

On Tue, Jan 24, 2012 at 1:59 AM, Steve Klabnik <steve@steveklabnik.com> wrote:

http://rack.rubyforge.org/

No idea. I'm not personally involved.

Rack 2.0 is being undertaken, and it's a huuuuge shift.

Will they finally change the name of their middleware components to
conform to English grammar?

("middleware" is a mass noun, like "furniture" and "water", and it
makes my skin crawl every time I read "that's a great middleware" or
the like.)

They've got a great metaphor already baked in -- why not call them
"shelves" or "units" or "pies" or something else that goes on a rack?

- A

P.S. There, I just logged it: https://github.com/rack/rack/issues/332

···

--
Alex Chaffee - alex@stinky.com
http://alexchaffee.com
http://twitter.com/alexch

Rack in general could use some help. I'm sure they'd love any help you
can give...

Will they finally change the name of their middleware components to
conform to English grammar?

("middleware" is a mass noun, like "furniture" and "water", and it
makes my skin crawl every time I read "that's a great middleware" or
the like.)

English is not my first language, but I'll dare to disagree with you
here. "ware", or "middleware", for me looks like a perfect regular
noun and I see no error in pluralizing it - "wares" or "middlewares"
sound just fine and keep the meaning of "multiple items of <x>", while
"waters" or "furnitures" don't.

They've got a great metaphor already baked in -- why not call them
"shelves" or "units" or "pies" or something else that goes on a rack?

This is just my opinion, but I think Ruby libraries already have
enough of clever puns with no benefit.

-- Matma Rex

···

2012/1/25 Alex Chaffee <alex@stinky.com>:

What help are you referring to? It doesn’t look as if there was much to do in the conceptual area, or at least there is no big ongoing discussion.

What would you like to see being changed or added to rack?

– Matthias

···

On 24.01.2012 16:33, Steve Klabnik wrote:

Rack in general could use some help.

English is not my first language, but I'll dare to disagree with you
here. "ware", or "middleware", for me looks like a perfect regular
noun and I see no error in pluralizing it - "wares" or "middlewares"
sound just fine and keep the meaning of "multiple items of <x>", while
"waters" or "furnitures" don't.

With all due respect, you are wrong.

A baker can sell his wares, but he cannot sell his ware.

This is an egregious, embarrassing linguistic error, on the scale of
using the wrong gender for a pronoun ("il aime son soeur") or the
wrong tense for a verb ("we will went to the movies") and if it
doesn't make your skin crawl, then you are not a bad person, but you
are also probably not a native English speaker.

See Mass noun - Wikipedia for the full scoop:

"In English, mass nouns are characterized by the fact that they cannot
be directly modified by a numeral without specifying a unit of
measurement, and that they cannot combine with an indefinite article
(a or an). Thus, the mass noun "water" is quantified as "20 liters of
water" while the count noun "chair" is quantified as "20 chairs".
However, mass nouns (like count nouns) can be quantified in relative
terms without unit specification (e.g., "much water," "many chairs")."

"software" is also a mass noun. You write a piece of software, or a
software program, never "a software".

They've got a great metaphor already baked in -- why not call them
"shelves" or "units" or "pies" or something else that goes on a rack?

This is just my opinion, but I think Ruby libraries already have
enough of clever puns with no benefit.

I agree with you there. I was kidding about the pies. :slight_smile:

(But not about "units" or "modules" or "parts" or something like that.)

- A

P.S. Ruby itself, since it was written mainly by non-native English
speakers, also has a few linguistic groaners, like using "case" to
mean "several cases" and "accessor" to mean "writer" (as well as
"reader").

···

2012/1/25 Bartosz Dziewoński <matma.rex@gmail.com>:

--
Alex Chaffee - alex@stinky.com
http://alexchaffee.com
http://twitter.com/alexch

Cookware. Silverware. Dinnerware. Software.

Not cookwares, silverwares, dinnerwares, or softwares.

It's not even wares. It's "Warez!", or something like that.

Hope that helps.

···

On Thu, Jan 26, 2012 at 04:10:05AM +0900, Bartosz Dziewoński wrote:

2012/1/25 Alex Chaffee <alex@stinky.com>:
> Will they finally change the name of their middleware components to
> conform to English grammar?
>
> ("middleware" is a mass noun, like "furniture" and "water", and it
> makes my skin crawl every time I read "that's a great middleware" or
> the like.)

English is not my first language, but I'll dare to disagree with you
here. "ware", or "middleware", for me looks like a perfect regular
noun and I see no error in pluralizing it - "wares" or "middlewares"
sound just fine and keep the meaning of "multiple items of <x>", while
"waters" or "furnitures" don't.

--
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]

Ofcourse, rack could always use some help, and from what I hear:
especially with pre-release testing.

But to respond back to the original poster, Ruby is perfectly capable
of producing a web application using the stdlib alone [1], but either
way you're going to be using a library for assistance and rack is
about as standard as it gets when it comes to web apps.

1: http://ruby-doc.org/docs/ProgrammingRuby/html/web.html

···

2012/1/24 Matthias Wächter <matthias@waechter.wiz.at>:

On 24.01.2012 16:33, Steve Klabnik wrote:

Rack in general could use some help.

What help are you referring to? It doesn’t look as if there was much to do
in the conceptual area, or at least there is no big ongoing discussion.

What would you like to see being changed or added to rack?

– Matthias

What help are you referring to? It doesn’t look as if there was much to do
in the conceptual area, or at least there is no big ongoing discussion.

Rack 2.0 is being undertaken, and it's a huuuuge shift.

Also, rack is basically maintained by just one guy at this point. At
least as a primary maintainer. Others chip in from time to time, of
course...