Re: [Rails-core] Suggestion: render filters

2015-06-17 Thread Ernie Miller
Hi Benjamin, This isn't really a valid use case. The way most of us would tackle something like this is to write a helper that lazy-loads the value in question, and call this from the view. This helper can exist in the controller class, if it needs access to your controller methods, and be

[Rails-core] Re: update_attribute violates POLA

2014-03-12 Thread Ernie Miller
# update_attribute is expected to update the specified attribute, not other ones. Thus it is violating POLA This is why you never want to rely on validates_uniqueness_of. It's essentially a convenience for generating pretty error messages. Use your DB's unique constraints to validate

Re: [Rails-core] Improving the ActiveRecord query API

2012-12-11 Thread Ernie Miller
On Tuesday, December 11, 2012 6:35:48 AM UTC-5, Rodrigo Rosenfeld Rosas wrote: But I find this more consisent: post[:dotted.column].like('zomg%') than this: post.__send__(:dotted.column).like('zomg%') You could actually support both syntaxes, but if you do so you wouldn't be able to

Re: [Rails-core] Improving the ActiveRecord query API

2012-12-10 Thread Ernie Miller
On Monday, December 10, 2012 4:08:06 PM UTC-5, Rodrigo Rosenfeld Rosas wrote: What if a column is named class? I'd rather prefer something like that: Post.where { |post| post[:title].like('zomg%') | post[:class].like('bbq%') } In Squeel's specific case, the DSL object is a

[Rails-core] Re: Need help porting limited eager loading optimization to Rails 3

2011-07-06 Thread Ernie Miller
: https://github.com/rails/rails/commit/08f3f30994d37f6f44acfac801f82fc43127fc78 . I don't think there's a quick (and also correct) way to fix this behavior, without modifying more than this one method. Jon or Aaron might tell me I'm wrong, though. :) -- Ernie Miller http://metautonomo.us -- You

Re: [Rails-core] [ANN] Rails 3.0.6.rc1

2011-03-30 Thread Ernie Miller
On Mar 30, 2011, at 7:18 PM, Aaron Patterson wrote: I'll be on vacation. :-D Fixed that for you. :) -- 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

Re: [Rails-core] ImageMagick and Rmagic gem

2011-03-22 Thread Ernie Miller
On Mar 22, 2011, at 11:26 AM, Gerő Zoltán wrote: Hi all, I need a little help. On Ubuntu ImageMagick packages installed. When I try to install rmagick gem I got this: ... checking for ImageMagick version = 6.4.9... no Can't install RMagick 2.13.1. You must have ImageMagick 6.4.9 or

[Rails-core] Re: Arel and a SafeBuffer?

2011-03-17 Thread Ernie Miller
On Mar 16, 6:15 pm, J Smith dark.pa...@gmail.com wrote: I know this sort of feature has the potential to be abused and lead to SQL injection attacks, so as a sanity check, I figured I'd check to see if this sort of feature would be useful or if I'm as crazy as I may potentially be for bringing

Re: [Rails-core] Possible bug with chained where methods on 3.0.4

2011-02-16 Thread Ernie Miller
On Feb 16, 2011, at 4:53 AM, Colin Law clan...@googlemail.com wrote: HI I notice on Rails 3.0.4 that the following two statements generate different results. State.where(:abbreviation = 'TX').where(:abbreviation = 'NE') SQL: SELECT `states`.* FROM `states` WHERE (`states`.`abbreviation` =

Re: [Rails-core] Possible bug with chained where methods on 3.0.4

2011-02-16 Thread Ernie Miller
On Feb 16, 2011, at 6:38 AM, Will Bryant will.bry...@gmail.com wrote: On Thu, Feb 17, 2011 at 12:21 AM, Ernie Miller er...@metautonomo.us wrote: Since your example above used a string in the second where call, it didn't result in an Arel::Nodes::Equality, so it wasn't ORed. Even on just

[Rails-core] Re: Possible bug with chained where methods on 3.0.4

2011-02-16 Thread Ernie Miller
On Feb 16, 7:24 am, Ernie Miller er...@metautonomo.us wrote: Sound arguments. I didn't implement collapse_wheres, just in case a witch hunt starts. I was just the first person awake this morning to pose the answer. :) The change probably shouldn't have made it into a point release, but I

Re: [Rails-core] Possible bug with chained where methods on 3.0.4

2011-02-16 Thread Ernie Miller
of my head. Happy to be corrected, though. -- Ernie Miller http://metautonomo.us http://github.com/ernie http://twitter.com/erniemiller -- 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

Re: [Rails-core] release more Arel power?

2011-02-16 Thread Ernie Miller
(off topic: this discussion is good to see, as I will be taking it into account on the metawhere rewrite) So, since this thread and another are currently ongoing relating to complex queries and the handling of ARel predicates, I thought I'd make a quick announcement that the MetaWhere

Re: [Rails-core] release more Arel power?

2011-02-16 Thread Ernie Miller
On Feb 16, 2011, at 7:19 PM, Nicolás Sanguinetti wrote: The definitely weirds me out. I haven't looked at the source, but why aren't you overriding ==? (a link to rtfm is fine, I'm just lazy :)) Honestly, I don't know. I thought about it, but something about overriding == even in this

Re: [Rails-core] eager load bug?

2011-02-15 Thread Ernie Miller
On Feb 15, 2011, at 5:07 AM, Robert Pankowecki robert.pankowe...@gmail.com wrote: o = Organization.first o.people.includes(:addresses).each do |p| puts p puts p.addresses end # 2 queries are executed, normal and for eager loading addresses but o.people.loaded? = false Is that a bug or

Re: [Rails-core] release more Arel power?

2011-02-13 Thread Ernie Miller
On Feb 13, 2011, at 3:22 AM, Prem Sichanugrist sikand...@gmail.com wrote: I've been discussed the possibility of exposing ARel power with the core team too, and found out that they thing ARel API is not mature enough to be exposed. Maybe we should wait :) In another hand, they don't like

Re: [Rails-core] release more Arel power?

2011-02-13 Thread Ernie Miller
On Feb 13, 2011, at 1:36 PM, Robert Pankowecki wrote: Wouldn't it be possible to implement the sexy api with blocks ? var = 12 # meta_where User.where(:id.gt var) # another implementation User.condition { id.gt var } Evaluate the the block in different scope in which title method

Re: [Rails-core] release more Arel power?

2011-02-13 Thread Ernie Miller
On Feb 13, 2011, at 12:42 PM, Chris Eppstein wrote: is it really that likely that your app is going to have a better use for something like Symbol#matches than to get an ARel Matches node? Case-in-point: the mongoid gem defines Symbol#matches. Libraries that do this have a myopic view of

Re: [Rails-core] release more Arel power?

2011-02-13 Thread Ernie Miller
On Feb 13, 2011, at 1:37 PM, Ted Han wrote: DataMapper has moved away from core patching (as we too think it's a bad idea). The symbol extensions that monkey patch core are opt-in now for legacy support, and i (amongst others) think it should go away all together. DataMapper's extended

[Rails-core] A patch for tricky joins causing table name collisions

2011-02-12 Thread Ernie Miller
children_people and landed on the same table name), and creates table name collisions. The patch at https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6423 fixes the regression and adds a test to cover it in the future. -- Ernie Miller http://metautonomo.us http://github.com

[Rails-core] Re: Remove ActiveRecord::Relation# alias for 'merge' ? (or at least only reference and not use in AR)

2011-02-10 Thread Ernie Miller
On Feb 10, 1:27 pm, Ernie Miller er...@metautonomo.us wrote: On Feb 10, 2011, at 1:21 PM, Aaron Patterson wrote: On Tue, Feb 08, 2011 at 12:54:40PM -0800, Brian Cardarella wrote: Would the core team be open to the removal of the '' alias for ActiveRecord::Relation#merge? Yes

[Rails-core] accepts_nested_attributes_for and :limit

2011-02-04 Thread Ernie Miller
When supplying a :limit option to accepts_nested_attributes_for, I found it a little bit surprising that records which are about to be destroyed count against the limit. From ActiveRecord::NestedAttributes#assign_nested_attributes_for_collection_association: if options[:limit]

Re: [Rails-core] Why does Rails not reset the association when the id is changed?

2011-02-04 Thread Ernie Miller
On Feb 4, 2011, at 3:30 PM, Paul wrote: Rails is great and most things just work easily. However, I've never been able to get a definite answer on whether one should do, validates :parent, :presence = true or, validates :parent_id, :presence = true given, class Parent end

[Rails-core] [PATCH] Polymorphic belongs_to association with :conditions issues

2011-01-11 Thread Ernie Miller
value in supplying :conditions to a polymorphic belongs_to, given the potential for major differences in the table being queried, might be debatable, but that's a separate issue. :) Thanks in advance! -- Ernie Miller http://metautonomo.us http://github.com/ernie http://twitter.com/erniemiller

Re: [Rails-core] Re: Are plugins still necessary in Rails3?

2010-12-08 Thread Ernie Miller
contain supporting software that's used in an integration, for instance. Put another way, vendor is the place for third-party (vendor) support files. -- Ernie Miller http://metautonomo.us http://github.com/ernie http://twitter.com/erniemiller -- You received this message because you are subscribed

Re: [Rails-core] Latest Version Number

2010-11-15 Thread Ernie Miller
In my opinion, the Rails version number should reflect the changes to the Rails API. The user-facing API did not see major changes due to the ARel rewrite. As the author of two gems (MetaWhere and MetaSearch) that are heavily dependent on ARel for their functionality, I released updated gems an

Re: [Rails-core] Re: Latest Version Number

2010-11-15 Thread Ernie Miller
help figuring out the layout of ARel 2, please drop me an e-mail. I've spent enough time digging around in it and submitting patches in both 1.x and 2.x that I should be able to help. That failing, Aaron's always been very responsive, in my experience. -- Ernie Miller http://metautonomo.us

[Rails-core] A few fixes to eager loading issues

2010-10-25 Thread Ernie Miller
elsewhere. Naturally, a uniq won't catch a situation as described above, since includes_values contains a symbol, :comments, and a hash, {:comments = :moderations}. Thanks in advance! -- Ernie Miller http://metautonomo.us http://github.com/ernie http://twitter.com/erniemiller -- You received

[Rails-core] Re: Unintended side-effect from before_remove_const?

2010-09-09 Thread Ernie Miller
. :) On Sep 8, 2010, at 2:58 PM, Ernie Miller wrote: Hey all, In troubleshooting a failing test for MetaSearch against 3-0-stable, I came across some undesirable (from my side, anyway) behavior in http://github.com/rails/rails/commit/bf87528b53f1422708ec0188d126cfca824ddc5c. A simple one

[Rails-core] Unintended side-effect from before_remove_const?

2010-09-08 Thread Ernie Miller
method I can find, in AR::Base, will not get the failures to stop. This is with Ruby 1.9.2-p0. Any insights (or even confirmations I'm not insane) would be appreciated. :) -Ernie -- Ernie Miller http://metautonomo.us http://github.com/ernie http://twitter.com/erniemiller -- You received

Re: [Rails-core] FormHelper and write-only fields

2010-08-27 Thread Ernie Miller
FormHelper needs a read method, too. You can return a blank string if you like but you need to respond_to the field name in question. You're most likely doing something that's not playing nicely with this commit's change to value_before_type_cast:

Re: [Rails-core] Exception Pages when behind a proxy

2010-07-26 Thread Ernie Miller
I took a quick glance at http://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/remote_ip.rb, and if I understand your description of the problem on the ticket, it may very well be the same old behavior that's been in Rails for ages. I wrote about it in detail a

[Rails-core] Any interest in a check_boxes helper?

2010-07-14 Thread Ernie Miller
So I currently have these helpers in MetaSearch because I use them when I create search forms myself, but I extracted them the other day for a post on forrst.com and I started to wonder why we don't already have something like this in Rails. Is the general consensus that this kind of stuff

Re: [Rails-core] Prepared SQL statements

2010-07-10 Thread Ernie Miller
On Jul 10, 2010, at 7:41 AM, Rodrigo Rosenfeld Rosas rr.ro...@gmail.com wrote: Ok, let me understand this better. I've just noted we are talking about a plugin, MetaWhere and not about Rails core behavior, right? bundle show doesn't list the meta-where plugin as a dependency of Rails...

Re: [Rails-core] Prepared SQL statements

2010-07-09 Thread Ernie Miller
On Jul 9, 2010, at 12:37 PM, Rodrigo Rosenfeld Rosas wrote: In Sequel, it is possible to call a sql method to see the generated SQL from a Sequel object. I missed this in ActiveRecord for a long time. I guess this is possible for ActiveRecord in Rails 3 since it is using Arel which takes

Re: [Rails-core] Prepared SQL statements

2010-07-09 Thread Ernie Miller
On Jul 9, 2010, at 6:57 PM, Rodrigo Rosenfeld Rosas wrote: Is it difficult to add some method to ActiveRecord that displays exactly the SQL that will be run, or that would be run if eager loading was set? I mean, maybe some methods like eager_sql and lazy_sql? I don't know ActiveRecord's

Re: [Rails-core] Prepared SQL statements

2010-07-09 Thread Ernie Miller
On Jul 9, 2010, at 7:33 PM, Rodrigo Rosenfeld Rosas wrote: I don't think it would be terribly difficult, no -- it'd basically be doing arel.to_sql or a partial version of find_with_associations depending on the result of eager_loading? that looks something like this and sticking it in

Re: [Rails-core] Adding scopes breaks migrations (Rails 3 beta 4)

2010-07-02 Thread Ernie Miller
I think the article entitled Named Scopes Are Dead had some good insights along those lines. http://www.railway.at/2010/03/09/named-scopes-are-dead/ In the Rails 3 app I've been working on, my scopes are just class methods like shown there. On Jul 2, 2010, at 6:57 AM, Paul Campbell

Re: [Rails-core] Adding scopes breaks migrations (Rails 3 beta 4)

2010-07-02 Thread Ernie Miller
/roadio/roadio/config/routes.rb:6 On a related note, time for me to go back and change my class method definitions back to scopes. :) On Jul 2, 2010, at 7:58 AM, Pratik wrote: I swear I had fixed this. Will have another look. On Fri, Jul 2, 2010 at 12:54 PM, Ernie Miller er...@metautonomo.us

Re: [Rails-core] Adding scopes breaks migrations (Rails 3 beta 4)

2010-07-02 Thread Ernie Miller
On Jul 2, 2010, at 9:11 AM, Paul Campbell wrote: defining an attribute based on a Ruby keyword (private). I'm pretty sure this isn't the case, since there's no private method name. Interestingly, it's very difficult to come up for a name in this that isn't a potential collision.

Re: [Rails-core] Adding scopes breaks migrations (Rails 3 beta 4)

2010-07-02 Thread Ernie Miller
On Jul 2, 2010, at 9:11 AM, Paul Campbell wrote: defining an attribute based on a Ruby keyword (private). I'm pretty sure this isn't the case, since there's no private method name. Interestingly, it's very difficult to come up for a name in this that isn't a potential collision. I

[Rails-core] Re: Edge: Multiple self-referencing eager loads don't join properly...

2010-06-07 Thread Ernie Miller
List, It's been a couple of weeks with no eyes on this simple patch, so I thought I'd ping the list again in the hopes that someone could give it a quick once-over. Thanks in advance! -Ernie On May 25, 2010, at 10:30 AM, Ernie Miller wrote: ...and it's my fault. :( Anyway, I have

Re: [Rails-core] Default JavaScript library

2010-05-27 Thread Ernie Miller
On May 27, 2010, at 12:51 PM, Daniel Schierbeck wrote: Xavier, I for one never use jRails -- in fact, neither do most of the rails devs i know. We do, however, use jQuery. The JavaScript helpers in Rails 2.3 were rather ugly, from a jQuery point of view, which probably explains why not that

[Rails-core] Edge: Multiple self-referencing eager loads don't join properly...

2010-05-25 Thread Ernie Miller
...and it's my fault. :( Anyway, I have a fix at https://rails.lighthouseapp.com/projects/8994/tickets/4679. Two lines of code, and a a test. Sorry! -Ernie -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Core group. To post to this group, send

[Rails-core] Re: Possible bug in JoinDependency code, and another take on inferred joins.

2010-04-26 Thread Ernie Miller
On Apr 23, 11:12 am, Ernie Miller er...@metautonomo.us wrote: While working on this, I came upon what I believe is a bug in a relatively unused part of the JoinDependency/eager_loading code pertaining to find_with_associations, though I may be mistaken. I've put up a lighthouse ticket

[Rails-core] Possible bug in JoinDependency code, and another take on inferred joins.

2010-04-23 Thread Ernie Miller
On Apr 20, 9:50 pm, Norman Clarke nor...@njclarke.com wrote: Definitely looks like a cool idea for a plugin though. You should keep working on it. I've got an alternate take on the concept up at http://github.com/ernie/meta_where/tree/autojoin now. I think I like this one better, and it seems

[Rails-core] Any interest in inferred joins?

2010-04-20 Thread Ernie Miller
I've been fiddling around a bit with the concept of adding inferred join capabilities to a gem I've been working on. The general idea, to me, is one that feels so Rails-like (as in, principle of least surprise) that I was kind of surprised it wasn't already in. The goal: If you're selecting

Re: [Rails-core] Any interest in inferred joins?

2010-04-20 Thread Ernie Miller
On Apr 20, 2010, at 9:42 PM, Pratik pratikn...@gmail.com wrote: I suppose you could override Relation#build_where def build_where(*args) if result = super case args.first when Hash # Figure out table names from *args here and add them to join_values or something

[Rails-core] Re: Access to more Arel predicate types from where condition hash

2010-04-15 Thread Ernie Miller
Thanks to a discussion with Pratik on #rails-contrib today, I decided to roll this into a gem instead: http://github.com/ernie/meta_where Consider the request for feedback on the patch revoked. :) Thanks! On Apr 12, 5:08 pm, Ernie Miller er...@metautonomo.us wrote: I could use some eyes

[Rails-core] Re: Unary and Polyadic predicates, notin and notmatch predicates for Arel

2010-04-13 Thread Ernie Miller
would optimize one better than the other. -Ernie Miller http://metautonomo.us -- 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-c...@googlegroups.com. To unsubscribe from this group, send

[Rails-core] [PATCH] Access to more Arel predicate types from where condition hash

2010-04-12 Thread Ernie Miller
I could use some eyes on https://rails.lighthouseapp.com/projects/8994/tickets/4368 if anyone has the time. Summary of the change: Similar to PredicateBuilder's existing support for 'table.column' = 'value', this patch enables 'column#method' = 'value'. For instance,

[Rails-core] Re: proxy_options on named scopes

2010-04-12 Thread Ernie Miller
On Apr 9, 9:06 pm, Matt Jankowski jankow...@gmail.com wrote: It looks like a recent documentation commit finally removed references to this method... http://github.com/rails/rails/commit/c6372d604952a8eef16ce73a06814aa1... In lieu of having #proxy_options available, is there another method

[Rails-core] Re: Unary and Polyadic predicates, notin and notmatch predicates for Arel

2010-04-09 Thread Ernie Miller
On Apr 8, 9:47 pm, Joe Smith unknown_kev_...@hotmail.com wrote: That breaks left to right readability pretty badly. I really would like a better solution for negating predicates and predicate chains, but I'm not sure what. I agree that I don't much like the way it just dangles there like

[Rails-core] Re: Unary and Polyadic predicates, notin and notmatch predicates for Arel

2010-04-09 Thread Ernie Miller
I agree that I don't much like the way it just dangles there like that, but I don't see any other way to accomplish what's desired. In working with it, I find that it helps to imagine yourself back in the 90s for a moment. User name equals Bill or user name equals Ted... NOT! OK, maybe

[Rails-core] [PATCH] Unary and Polyadic predicates, notin and notmatch predicates for Arel

2010-04-08 Thread Ernie Miller
Hi all. I was hoping to get some feedback on a patch to rails/arel I've put together. Not really sure where else to get some eyes on this, since Lighthouse doesn't seem appropriate given the separation of rails/arel from rails/rails. http://gist.github.com/360075 This patch adds support for

[Rails-core] Re: Unary and Polyadic predicates, notin and notmatch predicates for Arel

2010-04-08 Thread Ernie Miller
Err, minor correction. users[:name].matches_any('%Joe%', '%Bob%') is the syntax. I wrote the patch note last night and wasn't quite awake I guess. :) -- 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