Rails Cookbook review

Guys:

Stuck at the mall today, and just had to crack Rails Cookbook, by
O’Reilly. It
had a recipe for accepting dynamically created forms. The recipe
resolved to
build a grid on a page, and submit it with enumerable form post names.

The sample output looked like this (reconstructed):

p params[:my_form]

[“1-1” => 0, “1-2” => 0, “1-3” => 0, “2-1” => 0, “2-2” => 0,
“2-3” => 0, “3-1” => 0, “3-2” => 0, “3-3” => 0]

Does anyone have the book to hand? The technical problem here is…

A> naming a form field different from its ID is bad luck
B> an HTML ID should not start with a numeral (right?)

Can someone check if the book permits this bug in the IDs? Ruby form
helpers
make it kind’a easy…


Phlip

On Sat, Jul 26, 2008 at 10:12:21PM -0700, Phlip wrote:

 "2-3" => 0, "3-1" => 0, "3-2" => 0, "3-3" => 0]

Does anyone have the book to hand? The technical problem here is…

A> naming a form field different from its ID is bad luck

Where do you get this from? There’s nothing wrong with naming a form
field
something other than it’s ID, or not giving it an ID at all.

B> an HTML ID should not start with a numeral (right?)

I’d have to check the HTML/XML spec, but that sounds right. Anyway, the
simplest solution is to use the name prefixed with something (e.g.
dynamic_) as the ID. Mind you, I suspect most browsers will happily deal
with whatever string you put in the ID field, numeric or not.

Can someone check if the book permits this bug in the IDs? Ruby form
helpers make it kind’a easy…

I don’t even know what you’re asking here.

Phlip
–Greg

Gregory S. wrote:

A> naming a form field different from its ID is bad luck

Where do you get this from? There’s nothing wrong with naming a form field
something other than it’s ID, or not giving it an ID at all.

It’s just “bad luck”. As in “superstition causes bad luck”.

B> an HTML ID should not start with a numeral (right?)

I’d have to check the HTML/XML spec, but that sounds right.

I suspect some validators catch it, too.

I don’t even know what you’re asking here.

I did not buy the book. If anyone has it, can they check the source and
see if a
published Rails book lead users to create invalid IDs?

Ruby helpers, such as check_box_tag, tend to clone 'name’s to produce
'id’s. So
that’s one way Rails could accidentally generate invalid IDs…


Phlip

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs