Generating new project creates a few files with bad syntax Rails 3.2.1

session_store.rb

is: YourApplicationName::Application.config.session_store :cookie_store, key: ‘_yourapplicationname_session’

should be: YourApplicationName::Application.config.session_store :cookie_store, :key => ‘_yourapplicationname_session’

wrap_parameters.rb

is: wrap_parameters format: [:json]

should be: wrap_parameters :format => [:json]

ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0] LX9901145:initializers m2peters$ gem list

No, that is Ruby 1.9 hash syntax. It will generate that syntax if you’re using Ruby 1.9.

  • Prem

You’ve got to be kidding? Why do these people waste their time with such pointless syntactical changes? Does it improve performance? No. Does it improve readability? No.

Why does the comment in “wrap_parameters.rb” say the following?

Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.

Same reason people waste their time writing such pointless rage filled misinformed emails to mailing lists I guess. Does it improve understanding? No. Does it improve their perceived intelligence? No.

  • Don’t put a rage on me. I’m not the one who decide this. I explained why it’s being that way.

  • You can generate you application with old syntax by using --old-style-hash.

  • That wrap_parameters thing is something else altogether. It’s for when you’re calling @model.to_json.

  • Prem

Not sure where you got the “rage” from.

Again, not sure where you got the “rage” from.

I tend to get it from top-posting with no trimming :wink:

Just taking a long breath to answer you, this syntax change is not pointless, it’s a preparation for syntax like this:

some_method(name ‘bob’, age: 25)

in some_methods, the arguments is not a hash but they are named params…

Anyway, before this becomes a flame war again, post to rubyonrails-talk or ruby ML/IRC

Wael

So that’s what top-posting is. Why does Google Groups default to top-posting!!!

:slight_smile:

This is what would be gauged as “rage” here. They’re not pointless syntax changes. They’re adapting to the shorter syntax for hashes provided by 1.9. It didn’t have to be done, but it’s just nicer to have it.

Please don’t assume that they’re pointless. Most changes in Rails actually do have a point.

Ah, that makes it all better. Don’t they have better things to work on? (That’s a rhetorical question and not directed at you)

All these syntactic sugar changes just add to the barriers to entry. (I don’t blame you for this)

Isn’t “name ‘bob’” the syntax for passing “bob” as an argument into the “name” method? Or has that all changed too?

If I saw “name ‘bob’”, I would think that there’s a method named “name” defined somewhere.

def name(str)

do something with str

end

Isn't "name 'bob'" the syntax for passing "bob" as an argument into the "name" method? Or has that all changed too?

If I saw "name 'bob'", I would think that there's a method named "name" defined somewhere.

def name(str) # do something with str end

Sounds like a great question for rubyonrails-talk or ruby ML/IRC.

There's a mistyped there in the code. It has to be `name:`, not `name.`

Apparently all these syntactical changes confused you too :slight_smile:

I’m scared does “name.” mean something? For all I know it does now :slight_smile:

Oh, I put the period in the `` because the sentence ended there. Sorry if that's confused you.

The correct code is this:

    some_method(name: 'bob', age: 25)

- Prem

Any programmer worth his salt disobeys the imperfection of quotation punctuation rules :slight_smile:

Putting a period inside the quotes is like having two opening tags but only one closing tag.