Re: [Rails-core] [ANN] Rails 3.2.7.rc1 has been released!

2012-07-24 Thread Pedro Nascimento
Besides the update_attribute deprecation, everything works just fine.

On Mon, Jul 23, 2012 at 8:21 PM, Rodrigo Rosenfeld Rosas rr.ro...@gmail.com
 wrote:

 Em 23-07-2012 18:57, Aaron Patterson escreveu:

  Hi everyone!  I've pushed a release candidate for Rails 3.2.7.  Please
 try it
 out!  If you find any bugs present in the 3.2.7 release candidate that
 where not
 present in the 3.2.6 release, please report them to the Rails Core
 mailing list
 at here:


 https://groups.google.com/**group/rubyonrails-core/https://groups.google.com/group/rubyonrails-core/

 We do not want to break your application, so please take this opportunity
 to
 give the release candidate a try and report back!  Please find the list of
 changes in each gem's CHANGELOGE on the release branch here:


 https://github.com/rails/**rails/tree/3-2-relhttps://github.com/rails/rails/tree/3-2-rel

 A more comprehensive list of changes can be found here:


 https://github.com/rails/**rails/compare/v3.2.6...v3.2.7.**rc1https://github.com/rails/rails/compare/v3.2.6...v3.2.7.rc1

 If no show stopping bugs have been reported, I will release 3.2.7 final on
 Thursday the 26th (PDT).  Thanks!

 333


 Everything is green here both in my personal site (which has no test at
 all :P ) and in the application I'm developing/maintaining. But I should
 notice I'm not using AR so I can't tell you about it.

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To post to this group, send email to 
 rubyonrails-core@googlegroups.**comrubyonrails-core@googlegroups.com
 .
 To unsubscribe from this group, send email to
 rubyonrails-core+unsubscribe@**googlegroups.comrubyonrails-core%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/**
 group/rubyonrails-core?hl=enhttp://groups.google.com/group/rubyonrails-core?hl=en
 .



-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.



[Rails-core] Behavior of first_or_create

2012-07-24 Thread Matt Jones
I just ran across a weird glitch (IMHO) in find_or_create. The arguments passed 
to it are *not* added to the conditions for the 'first' part. This is odd, 
given that it's intended to replace find_or_create_by_* methods, which *did* 
use the specified values as conditions.

I'm unsure on whether this behavior is entirely undesirable, but it's 
definitely not what I had expected in my use case (ensuring that a join table 
record exists). Perhaps there should be a variant (find_or_create_exactly, 
perhaps?) that uses the supplied attributes as additional conditions. 

If nothing else, the documentation should be updated to reflect this scenario - 
the last case in the examples *almost* describes this scenario, but the block 
form used there makes it unclear what:

User.where(:first_name = 'Scarlett').first_or_create(:last_name = O'Hara)

would do. 

I also found that DataMapper implements the behavior I was expecting in their 
first_or_create method:

https://github.com/datamapper/dm-core/blob/master/lib/dm-core/model.rb#L448

Thoughts?

--Matt Jones


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.



Re: [Rails-core] Behavior of first_or_create

2012-07-24 Thread Andrés Mejía
I would definitely expect

User.where(:first_name = 'Scarlett').first_or_create(:last_name =
O'Hara)

to call

User.create(:first_name = 'Scarlett', :last_name = O'Hara)

if that's not what's happening then I think it's a bug and should be fixed.
Matt, do you have a minimal app that shows the problem? I would like to
write a test case for Rails that shows this strange behavior.


On Tue, Jul 24, 2012 at 2:43 PM, Matt Jones al2o...@gmail.com wrote:

 I just ran across a weird glitch (IMHO) in find_or_create. The arguments
 passed to it are *not* added to the conditions for the 'first' part. This
 is odd, given that it's intended to replace find_or_create_by_* methods,
 which *did* use the specified values as conditions.

 I'm unsure on whether this behavior is entirely undesirable, but it's
 definitely not what I had expected in my use case (ensuring that a join
 table record exists). Perhaps there should be a variant
 (find_or_create_exactly, perhaps?) that uses the supplied attributes as
 additional conditions.

 If nothing else, the documentation should be updated to reflect this
 scenario - the last case in the examples *almost* describes this scenario,
 but the block form used there makes it unclear what:

 User.where(:first_name = 'Scarlett').first_or_create(:last_name =
 O'Hara)

 would do.

 I also found that DataMapper implements the behavior I was expecting in
 their first_or_create method:

 https://github.com/datamapper/dm-core/blob/master/lib/dm-core/model.rb#L448

 Thoughts?

 --Matt Jones


 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-core+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-core?hl=en.



-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.



Re: [Rails-core] Behavior of first_or_create

2012-07-24 Thread Matt Jones

On Jul 24, 2012, at 4:04 PM, Andrés Mejía wrote:

 I would definitely expect
 
 User.where(:first_name = 'Scarlett').first_or_create(:last_name = O'Hara)
 
 to call
 
 User.create(:first_name = 'Scarlett', :last_name = O'Hara)
 
 if that's not what's happening then I think it's a bug and should be fixed. 
 Matt, do you have a minimal app that shows the problem? I would like to write 
 a test case for Rails that shows this strange behavior.

Nope, that's not exactly what I observed; I'll try again. That code *does* call 
the create correctly, if there are no users with the correct first_name. The 
confusing part to me was that it wasn't quite the same as this:

User.where(:first_name = 'Scarlett').find_or_create_by_last_name(O'Hara)

The latter includes a condition on last_name in the find, where the former does 
not.

Given that the dynamic form is deprecated (targeted for removal in 4.1 - see 
active_record_deprecated_finders for details), it's worth either matching the 
old behavior or clearly documenting the difference to avoid confused upgraders.

--Matt Jones


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.



Re: [Rails-core] Behavior of first_or_create

2012-07-24 Thread Jon Leighton

On 24/07/12 21:29, Matt Jones wrote:


On Jul 24, 2012, at 4:04 PM, Andrés Mejía wrote:


I would definitely expect

User.where(:first_name = 'Scarlett').first_or_create(:last_name = O'Hara)

to call

User.create(:first_name = 'Scarlett', :last_name = O'Hara)

if that's not what's happening then I think it's a bug and should be fixed. 
Matt, do you have a minimal app that shows the problem? I would like to write a 
test case for Rails that shows this strange behavior.


Nope, that's not exactly what I observed; I'll try again. That code *does* call 
the create correctly, if there are no users with the correct first_name. The 
confusing part to me was that it wasn't quite the same as this:

User.where(:first_name = 'Scarlett').find_or_create_by_last_name(O'Hara)

The latter includes a condition on last_name in the find, where the former does 
not.


This behaviour is intentional. The dynamic version did actually 
previously take an options hash of stuff that would get passed to 
create. So:


User.where(:first_name = 
'Scarlett').find_or_create_by_last_name(O'Hara, :age = 32)


would do:

User.where(:first_name = Scarlett, :last_name = O'Hara)

and then:

User.create(:first_name = Scarlett, :last_name = O'Hara, :age = 32)

I believe the rationale is simply that you can put all of your 
conditions in a where()


--
http://jonathanleighton.com/

--
You received this message because you are subscribed to the Google Groups Ruby on 
Rails: Core group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.



[Rails-core] Re: [ANN] Rails 3.2.7.rc1 has been released!

2012-07-24 Thread Steve Jorgensen
Great! Yet another release that does not include the bug fix  test 
coverage in https://github.com/rails/rails/pull/6654. Hint, hint. :)

On Monday, July 23, 2012 2:57:46 PM UTC-7, Aaron Patterson wrote:

 Hi everyone!  I've pushed a release candidate for Rails 3.2.7.  Please try 
 it 
 out!  If you find any bugs present in the 3.2.7 release candidate that 
 where not 
 present in the 3.2.6 release, please report them to the Rails Core mailing 
 list 
 at here: 

 snip 

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/NjC-J00SMfkJ.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.