Rails for the Rubyist

It’s very nice that DAB has written “Ruby for Rails”, which (as I
understand it) helps Rails developers learn Ruby.

What’s the best source for the opposite? Learning Rails for those who
already know Ruby? I’m frustrated by the number of intro tutorials to
rails that have things like “I learned that @foo is called an ‘instance
variable’”.

I’m not sure what form this should take, but some insight into the
inner workings (dispatch diagrams, how/when rails reloads files, etc.)
seem to be in order.

While I’m asking for some me-centric stuff, how about the best resource
for “Rails for the veteran web developer who’s used to rolling every
bit of HTML and CSS and JS by hand and is having trouble learning to
re-use existing helper methods, and is instead spending gobs of time
writing ‘convenience’ methods when that time should be spent cranking
out the site.” :slight_smile:

While I’m asking for some me-centric stuff, how about the best resource
for “Rails for the veteran web developer who’s used to rolling every
bit of HTML and CSS and JS by hand and is having trouble learning to
re-use existing helper methods, and is instead spending gobs of time
writing ‘convenience’ methods when that time should be spent cranking
out the site.” :slight_smile:

I found the pragmatic books to be pretty good…

http://www.pragmaticprogrammer.com/titles/rails/index.html
http://www.pragmaticprogrammer.com/titles/fr_rr/index.html

I didn’t know ruby before rails, but did read through the free
programming
ruby book and a couple of other references on ruby first… i believe
one
of the above books had a ruby appendix…

There’s a section on action-view which has all the helper methods in it.
and I got in the habit of every time I thought there should be a helper
to
do this would go and look if that was indeed the case… usually there
was, sometimes not though.

-philip

On 26 Sep 2006, at 00:10, Phrogz wrote:

What’s the best source for the opposite? Learning Rails for those who
already know Ruby? I’m frustrated by the number of intro tutorials to
rails that have things like “I learned that @foo is called an
‘instance
variable’”.

I spent time banging my head on the desk when I was trying to pick up
Rails, too. Plus I suffer from terminal overdose of cuteness
whenever I come within 20 yards of those “Head First” books.

While I’m asking for some me-centric stuff, how about the best
resource
for “Rails for the veteran web developer who’s used to rolling every
bit of HTML and CSS and JS by hand and is having trouble learning to
re-use existing helper methods, and is instead spending gobs of time
writing ‘convenience’ methods when that time should be spent cranking
out the site.” :slight_smile:

Yup, that’s me!

Agile Web D. with Rails (2nd Ed) is going to be your answer,
but I think you’d enjoy Ruby for Rails, too; I know I did.

Paul

writing ‘convenience’ methods when that time should be spent cranking
out the site." :slight_smile:

Here is a little diagram I created specifically for my MVC framework
(one I wrote for PHP5) which is very similar to Rails:

http://c.anvas.es/docs/images/flow_of_a_request.png

As far as learning Rails, just gleaning through the Agile Web Dev w/
Rails book is probably your best bet, and experimenting. I know the
Rails Recipes book is really good, though, and will answer a lot of
the questions you might have as well. It’s learning by example.

M.T.

Rails Recipe’s was my thought too. It’s basically walks you through
solid approaches to various problems, you’ll recognize most
everything, but will help you get your mind on the right track. I
still find my AWD to be a very useful resource. Additionally there
is a wealth of information online, especially look for open source
rails apps, download the whole thing and read the source. What you
don’t understand look up in AWD.

On 9/25/06, Paul L. [email protected] wrote:

for “Rails for the veteran web developer who’s used to rolling every
bit of HTML and CSS and JS by hand and is having trouble learning to
re-use existing helper methods, and is instead spending gobs of time
writing ‘convenience’ methods when that time should be spent cranking
out the site.” :slight_smile:

Yup, that’s me!

Agile Web D. with Rails (2nd Ed) is going to be your answer,
but I think you’d enjoy Ruby for Rails, too; I know I did.

I haven’t seen Ruby for Rails, so I don’t know the balance between
Ruby and Rails. I’ve heard good things about it, but is it really the
right choice for someone who already knows Ruby and is trying to learn
rails?

I’ve found that, as in development, an incremental or spiral approach
works best for me.

When I first heard about Ruby, I focused on the language and worked
through the on-line version of the first ed of the Pickaxe. Then I
got interested in Rails, and bought Agile Web D… Then I
bought the Pickaxe and got really serious about the language.

Now I’m working through the new edition of AWDWR, and rather than just
slavishly following Dave’s examples, I’m playing with them, using the
Ruby knowledge that I’ve acquired, and seeing how it works in Rails.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

From: [email protected]
Bcc:
Message-ID: [email protected]
X-OriginalArrivalTime: 26 Sep 2006 21:51:04.0217 (UTC)
FILETIME=[DD253090:01C6E1B5]
Date: 26 Sep 2006 14:51:04 -0700

Hi everyone,

I was just wondering if anyone can recommend a good image capture
library/package that can be used with Ruby/Watir? We need to do pretty
basic
image capture like capture a specific window, or a specific frame within
a
window and then save the image as a bmp or jpg file.

Thanks in advance,

Steve Tang

On 26 Sep 2006, at 21:04, Rick DeNatale wrote:

writing ‘convenience’ methods when that time should be spent
right choice for someone who already knows Ruby and is trying to learn
rails?

I said that I think he would enjoy it - because it avoids the “gee
whiz” web designer approach to the essential Ruby core of Rails, and
does manage to explain various aspects of Rails from a Rubyphile
perspective.

I’ve found that, as in development, an incremental or spiral approach
works best for me.

Now I’m working through the new edition of AWDWR, and rather than just
slavishly following Dave’s examples, I’m playing with them, using the
Ruby knowledge that I’ve acquired, and seeing how it works in Rails.

The latest edition is looking to become radically different from the
first, in a good way.

Paul

Paul L. wrote:

On 26 Sep 2006, at 00:10, Phrogz wrote:

What’s the best source for the opposite? Learning Rails for those who
already know Ruby? I’m frustrated by the number of intro tutorials to
rails that have things like “I learned that @foo is called an
‘instance variable’”.
[snip]
Agile Web D. with Rails (2nd Ed) is going to be your answer,
but I think you’d enjoy Ruby for Rails, too; I know I did.

I just bought the PDF, and I’m not very far into it, but I’ve already
found this section:

"In the description of views and controllers, we showed the controller
setting the
time to be displayed into an instance variable. The .rhtml file used
that instance
variable to substitute in the current time. But the instance data of
the controller
object is private to that object. How does ERb get hold of this private
data to
use in the template?

The answer is both simple and subtle. Rails does some Ruby magic so
that
the instance variables of the controller object are injected into the
template
object. As a consequence, the view template can access any instance
variables
set in the controller as if they were its own.

Some folks press the point: “just how do these variables get set?”
These folks
clearly don’t believe in magic. Avoid spending Christmas with them."

Very amusing, but exactly the sort of explanation and attitude that I
was hoping to avoid. Ah well; certainly other good information in it so
far. (I’m also discouraged by the appearance that the book takes the
track of “If you use an RDBMS other than MySQL, it’ll mostly work, but
you’re on your own when you run into trouble.”)

Steve Tangsombatvisit wrote:

From: [email protected]
Bcc:
Message-ID: [email protected]
X-OriginalArrivalTime: 26 Sep 2006 21:51:04.0217 (UTC)
FILETIME=[DD253090:01C6E1B5]
Date: 26 Sep 2006 14:51:04 -0700

Hi everyone,

I was just wondering if anyone can recommend a good image capture
library/package that can be used with Ruby/Watir? We need to do pretty
basic
image capture like capture a specific window, or a specific frame within
a
window and then save the image as a bmp or jpg file.

Thanks in advance,

Steve Tang

We’re using TechSmith’s SnagIt to capture screenshots during the
automated test runs. SnagIt can function as an OLE automation server,
saves the images to a file, clipboard. You can capture an entire screen,
a region of the screen, a scrolling web page, you name it. I’ve written
a ScreenCapture class that encapsulates all the COM stuff.

A fully functional 30-day trial version can be downloaded from here…
Download Free Trial | Snagit | TechSmith

The COM server examples and documentation can be found here…
Premium Royalty-Free Snagit Assets | TechSmith

On 9/27/06, Patrick S. [email protected] wrote:

Hi everyone,

I was just wondering if anyone can recommend a good image capture
library/package that can be used with Ruby/Watir? We need to do pretty
basic
image capture like capture a specific window, or a specific frame within
a
window and then save the image as a bmp or jpg file.

I thought that WATIR already had some basic screencapture stuff
built-in?

Probably quite primitive though.

Richard C. wrote:

I thought that WATIR already had some basic screencapture stuff
built-in?

Probably quite primitive though.

We opted for SnagIt because of it’s ability to capture a scrolling page,
from top to bottom, capturing the entire page. I’ve been using SnagIt
since version 5.x, when it didn’t have the automation capabilities,
which meant resorting to DDE… ugly! The ScreenCapture class I
mentioned earlier handles all the “grunt” work of capturing the screen,
saving it to a file, then opening the file in binary mode, read in each
byte and store it in an image type field in a SQL Server table. I
would’ve rather done away with all disk I/O stuff, but couldn’t come up
with a means to collect the image directly from the clipboard. Most of
the Ruby modules that address the Windows clipboard seem to cater to
text, vs. images. In any case, it’s pretty damned quick, and… “if it
ain’t broke, don’t fix it!”

On 9/27/06, Phrogz [email protected] wrote:

data to
Some folks press the point: “just how do these variables get set?”
These folks
clearly don’t believe in magic. Avoid spending Christmas with them."

Very amusing, but exactly the sort of explanation and attitude that I
was hoping to avoid. Ah well; certainly other good information in it so
far. (I’m also discouraged by the appearance that the book takes the
track of “If you use an RDBMS other than MySQL, it’ll mostly work, but
you’re on your own when you run into trouble.”)

Regarding this particular magic, I’m pretty sure all Rails does is
loop through all the instace variables on the controller, do a
instance_variable_get to grab it and then an instance_variable_set to
store it on the template object. So it just uses some the
instance_variable* methods to bypass encapsulation and throw
everything onto the template.

  • rob

“Rob S.” [email protected] writes:

Regarding this particular magic, I’m pretty sure all Rails does is
loop through all the instace variables on the controller, do a
instance_variable_get to grab it and then an instance_variable_set to
store it on the template object. So it just uses some the
instance_variable* methods to bypass encapsulation and throw
everything onto the template.

What again was MVC for?

Phrogz wrote:

What’s the best source for the opposite? Learning Rails for those who
already know Ruby? I’m frustrated by the number of intro tutorials to
rails that have things like “I learned that @foo is called an ‘instance
variable’”.
I learned Rails after 4 months of Ruby, and my approach was basically:

  1. Watch the screencast.
  2. Start writing a Rails app (keeping a tab open to
    api.rubyonrails.org).
  3. Watch the screencast again.
  4. Subscribe to some Rails-related RSS feeds.
  5. Figure out a way to get paid to write Rails apps.
  6. Read the Rails source as you need/desire.

That was starting around 0.9, though. The Rails world has grown, so I
dunno if that’s a good approach any more. (For that matter, I dunno if
it was a good approach back then, but it seems to have worked.)

(I’m also discouraged by the appearance that the book takes the
track of “If you use an RDBMS other than MySQL, it’ll mostly work, but
you’re on your own when you run into trouble.”)
Not just the book… I get the impression the committers do, too. The
adapters are there, and are constantly being improved, but don’t seem to
be as up to snuff as, oh, say, the one that DHH uses.

Devin

On 9/27/06, Devin M. [email protected] wrote:

Phrogz wrote:

(I’m also discouraged by the appearance that the book takes the
track of “If you use an RDBMS other than MySQL, it’ll mostly work, but
you’re on your own when you run into trouble.”)
Not just the book… I get the impression the committers do, too. The
adapters are there, and are constantly being improved, but don’t seem to
be as up to snuff as, oh, say, the one that DHH uses.

I don’t really agree about the last point there. I don’t feel that
MySQL is even the best Rails adapter right now. The PostgreSQL and
Oracle adapters are each better in a fair number of ways.
If you’re not working from example SQL code that is MySQL-specific, or
from the sample gibberish that MySQL happens to call DDL (sorry,
couldn’t resist), you shouldn’t even notice which DBMS platform you’re
on.

The more obscure adapters are almost certainly less fun to use,
though… anything without a really nice Ruby library under the hood is
probably going to get in your way at some point.

I was also under the impression that the quality of the Rails
adapters was more or less directly connected with the underlying ruby
library. I also feel its pretty reasonable for a book designed to
cover a framework, parts of a language, and a development methodology
to limit its coverage on databases to the de facto standard “entry”
database in the interest of brevity and remaining focused. It
shouldn’t be hard to extrapolate the knowledge to other adapters.

(just because mysql seems to be the default doesn’t mean its the best
example, but it does mean that people choosing other adapters are
much more likely to readily find and understand the knowledge they
need to make theirs work)

Hi –

On Thu, 28 Sep 2006, Christian N. wrote:

“Rob S.” [email protected] writes:

Regarding this particular magic, I’m pretty sure all Rails does is
loop through all the instace variables on the controller, do a
instance_variable_get to grab it and then an instance_variable_set to
store it on the template object. So it just uses some the
instance_variable* methods to bypass encapsulation and throw
everything onto the template.

What again was MVC for?

It’s always been a bit like M(VC). I think the instance variable
thing is a reasonable way for controllers to hand off data to the
views, which has to happen somehow.

One thing I’ve always liked about the Rails meta-programming stuff is
that even when it gets rather complex and tricky, it tends to lead
ultimately to simplicity. It’s definitely a domain-specific
re-invention of the instance variable, though.

David

On 27 Sep 2006, at 16:40, Phrogz wrote:

that instance variable to substitute in the current time. But the
variables set in the controller as if they were its own.
you’re on your own when you run into trouble.")
Just for clarity, that quote is from a “Joe Asks” pull out in AWDwR,
not Ruby for Rails. Joe being the archetypal newbie programmer. I
think that’s excusable, until we find the perfect text for explaining
OOP and MVC; if anyone knows of it, I’d love to hear from you.

Paul

On 9/27/06, Phrogz [email protected] wrote:

Very amusing, but exactly the sort of explanation and attitude that I
was hoping to avoid. Ah well; certainly other good information in it so
far. (I’m also discouraged by the appearance that the book takes the
track of “If you use an RDBMS other than MySQL, it’ll mostly work, but
you’re on your own when you run into trouble.”)

Yes, well. That’s the way that Rails works, not just the book. I’ve
already found my purchase of the book useful because it helped me get
my wedding guest tracker application going.

(No, this app will probably never be public. It’s for my wedding.)

-austin