Spaces in between brackets

S

semmons99

Can anyone explain to me why the code works:

<input id="recipe_title" name="recipe[title]"

While this code doesn't:

<input id="recipe_title" name="recipe[ title ]"

I know that most people don't put spaces in between brackets, however I
like to for readability. It seems like I can do this everywhere in Ruby
and Rails except for the name of html tag. Any thoughts on why this is?
 
J

James Britt

Can anyone explain to me why the code works:

<input id="recipe_title" name="recipe[title]"

While this code doesn't:

<input id="recipe_title" name="recipe[ title ]"

I know that most people don't put spaces in between brackets, however I
like to for readability. It seems like I can do this everywhere in Ruby
and Rails except for the name of html tag. Any thoughts on why this is?

Because Rails magically converts "recipe[ title ]" into
recipe[" title "]

And " title " != "title"

But, for the future, you would do better to direct Rails questions to
the Rails mailing list.



--
James Britt

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
 
J

Jim Freeze

Because Rails magically converts "recipe[ title ]" into
recipe[" title "]

And " title " != "title"

But, for the future, you would do better to direct Rails questions
to the Rails mailing list.

I don't know. Seems like he got his question answered pretty well on
this list.

Jim Freeze
 
J

James Britt

Jim said:
Because Rails magically converts "recipe[ title ]" into
recipe[" title "]

And " title " != "title"

But, for the future, you would do better to direct Rails questions to
the Rails mailing list.


I don't know. Seems like he got his question answered pretty well on
this list.

Yeah, well, it happens. (And this was one of those unintuitive Rails
things that bit me, too, so I'm sympathetic.)


--
James Britt

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
 
J

Jim Freeze

Jim said:
Because Rails magically converts "recipe[ title ]" into
recipe[" title "]

And " title " != "title"

But, for the future, you would do better to direct Rails
questions to the Rails mailing list.
I don't know. Seems like he got his question answered pretty well
on this list.

Yeah, well, it happens. (And this was one of those unintuitive
Rails things that bit me, too, so I'm sympathetic.)

We need to tell those rails core folks about #strip. And, #strip! is
very fast.

Jim Freeze
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top