Mass assignment weirdness #478

Closed
qoobaa opened this Issue May 10, 2011 · 7 comments

Projects

None yet

2 participants

Contributor
qoobaa commented May 10, 2011

I'm not sure if it's intentional or not, but it's definitely quite confusing:

>> Goal.new(nil)
=> #<Goal id: nil>
>> Goal.first.update_attributes(nil)
NoMethodError: undefined method `stringify_keys' for nil:NilClass
>> Goal.first.invitations.build(nil)
=> nil
>> Goal.first.invitations.new(nil)
=> #<Goal::Invitation id: nil, goal_id: 1>

Ruby 1.9.2p180, Rails 3.1.0.beta1.

Member

Could you quickly check if "Goal.first.update_attributes(nil)" works on Rails 3.0?

Contributor
qoobaa commented May 10, 2011
>> Goal.new(nil)
=> #<Goal id: nil>
>> Goal.first.update_attributes(nil)
=> true
>> Goal.first.invitations.build(nil)
=> #<Goal::Invitation id: nil, goal_id: 1>
>> Goal.first.invitations.new(nil)
=> #<Goal::Invitation id: nil, goal_id: 1>

Rails 3.0.7.

Member

Sweet, I am going to fix this in a couple minutes.

Contributor
qoobaa commented May 10, 2011

There's one more glitch:

>> Goal.first.invitations.build
WARNING: Can't mass-assign protected attributes: goal_id
=> #<Goal::Invitation id: nil, goal_id: nil>

In 3.1.0.beta1.

Contributor
qoobaa commented May 10, 2011
>> Goal.first.invitations.build
=> #<Goal::Invitation id: nil, goal_id: 1>

Rails 3.0.7.

@josevalim josevalim was assigned May 10, 2011
Member

@qoobaa can you please open a new issue for the other glitch? Thanks!

@josevalim josevalim closed this in 9e4b715 May 10, 2011
Contributor
qoobaa commented May 10, 2011

Done => #479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment