Re: [Rails-core] Re: [Feature Request] When performing find by multiple ids, return partial results on RecordNotFound error.

2016-06-21 Thread Al Tenhundfeld
John, I was trying to formulate those same thoughts. Thanks. I think there's a reasonable case for enhancing the error message to include which were found (or missing). I don't see a big downside, and it would assist troubleshooting the unexpected problem. In addition to the behavior-incentivizin

Re: [Rails-core] Pessimistic Locking

2016-01-05 Thread Al Tenhundfeld
Not sure what you mean about Rails "not supporting real database foreign keys". 1) They are officially supported (as of Rails 4.2, I think) and documented in the RailsGuides. 2) It's always been easy to add support via gem

Re: [Rails-core] ActiveSupport::HashWithIndifferentAccess integer

2015-09-21 Thread Al Tenhundfeld
I can't really speak to the usefulness of this, but I think you'll meet resistance due it being a breaking change. HashWithIndifferentAccess allows other types of keys; it just doesn't convert the key to string, as it does with symbols. Current behavior: hash = HashWithIndifferentAccess.new({"1"

Re: [Rails-core] RFC: Remove support for passing argument to force association reload

2015-07-15 Thread Al Tenhundfeld
Another idea for the work-around is to add a reload_* association method, e.g., user.reload_profile. I'm not sure it's worth adding yet another generated association method (or even a good idea), but that would make the reload interface consistent with the build_* and create_* association methods,

Re: [Rails-core] Add a hash pluck method?

2015-06-26 Thread Al Tenhundfeld
The proposed method has more benefit when plucking multiple columns. Of course, you can still do pluck(:first, :last, :dob).map {|e| {first: e[0], last: e[1], dob: e[2]} }, but I guess that's a little cumbersome and smelly. I'm not arguing the benefit – small benefit IMO – is worth the cost of addi

Re: [Rails-core] ActiveRecord::Querying#find_by_sql has a confusing interface?

2015-06-26 Thread Al Tenhundfeld
'select * from posts where id = ?', [id_query_attribute]) > > On Fri, Jun 26, 2015 at 1:05 PM, Al Tenhundfeld > wrote: > >> If I'm following the code, it looks like the binds argument is passed >> through #select_all and eventually down to the adapter's #exec_

Re: [Rails-core] ActiveRecord::Querying#find_by_sql has a confusing interface?

2015-06-26 Thread Al Tenhundfeld
If I'm following the code, it looks like the binds argument is passed through #select_all and eventually down to the adapter's #exec_query, e.g., the MySQL adapter

Re: [Rails-core] Adding dirty checking by default to uniqueness validations

2014-11-07 Thread Al Tenhundfeld
Hey Ryan, No idea if this would be accepted, but I have two questions: 1) Do any other validators have this behavior? I don't think so, but I'm not sure. Consistency isn't always the highest priority, but it's an important consideration. I guess you could argue that this validator is special beca

Re: [Rails-core] [Feature request] content_tag do |el| ... end to create complex tags

2014-10-27 Thread Al Tenhundfeld
I want to set aside the arguments on whether this would encourage less clean code or move Rails in good direction. I can imagine scenarios where this would be useful in hectic, real-world development. However, that should not be the standard for including functionality in Rails. I imagine the Rail

Re: [Rails-core] Improvements to Strong Params

2014-05-03 Thread Al Tenhundfeld
Alexander, In your last example, I think `require` would actually work fine as-is, i.e., params.require(:one).require(:one) would check the presence of the root and the specified child node. That said, I think you have a good point that `require` may be a little too strongly opinionated and lacks

Re: [Rails-core] ActiveRecord chained order calls composed

2014-04-14 Thread Al Tenhundfeld
+1 I don't think of ActiveRecord as an API for manipulating collections of data but instead an API for composing queries (and mapping data, etc.). I don't know what's "correct", but it feels intuitive to me that order calls would be composed consistently with where calls. -Al On Mon, Apr 14, 201

Re: [Rails-core] SQL adapter convert Date objects automatically to DateTime ranges.

2014-02-06 Thread Al Tenhundfeld
It depends on the database. In general, when you manipulate the left-hand side of a WHERE clause, the planner punts, but I know some databases have been adding sophistication to handle some common (deterministic) functions. I read MS SQL Server (since v2008) will use an index on a DateTime field f

Re: [Rails-core] validates :boolean_field, presence: true misconceptions

2013-11-14 Thread Al Tenhundfeld
Sergio, When I was starting with Rails, I felt a similar dissonance about the presence validator, but as you say, it's important to think of validations in the context of Rails. After all, an empty string is not NULL in the database but would also fail the presence validator. As Rafael said, the o

Re: [Rails-core] How do I Create a Scope for Last Month?

2013-08-01 Thread Al Tenhundfeld
This mailing list for the discussion of development of core Rails features. For support please consider using Stackoverflow, Quora, #RubyOnRails on IRC or the rubyonrails-talk mailing list. I sent you a reply off list. -Al On Thu, Aug 1, 2013 at 11:06 PM, wrote: > I have a Rails 3.2 app with a