Re: [Rails-core] Can we move the "helpers" folder to "views/helpers"?

2012-12-18 Thread Nicolás Sanguinetti
If, for whatever reason, it makes sense to have a HelpersController in your app, now you have a name clash and have to work around it. IMHO there's nothing wrong with app/helpers per se. If you think the problem is a lack of documentation, that would be the place to improve :) Cheers, -foca On

Re: [Rails-core] update_all isn't as expressive as it should be

2013-01-04 Thread Nicolás Sanguinetti
What's wrong with Model.update_all('column1 = column2 + column3') ? This has been possible since forever :) Cheers, -foca On Fri, Jan 4, 2013 at 6:46 AM, Radu Dinca wrote: > I would like to be able to do the following : > > UPDATE table SET column1 = column2 + column3 -> for the whole table , a

Re: [Rails-core] [ActiveRecord] scope for collection associations

2013-05-21 Thread Nicolás Sanguinetti
IIRC with Rails 4 associations introduce their methods via a module, which means you can `super` to them, so why not: class Post has_many :comments def comments(*) super.visible end end I'm not too keen on having moar DSL when defining a simple method suffices. It also gives you more f

Re: [Rails-core] [ActiveRecord] scope for collection associations

2013-05-22 Thread Nicolás Sanguinetti
luding > the hidden ones? I'm thinking of passing a parameter to the comments method. > > class Post > has_many :comments > > def comments(show_hidden = false) > show_hidden ? super : super.visible > end > end > > Is this the right way? > > -- > Dh

Re: [Rails-core] Allow hash for conditional class attribute in tag helper

2014-03-05 Thread Nicolás Sanguinetti
You can pass Arrays to the `class:` option and it will do what you expect it to: link_to(post.title, post, class: ["post", "active" if post.active?]) Cheers, -foca On Wed, Mar 5, 2014 at 1:36 PM, Stefan Schüßler wrote: > When dealing with conditional class attribute values in HTML tags, I

Re: [Rails-core] Allow hash for conditional class attribute in tag helper

2014-03-05 Thread Nicolás Sanguinetti
Sorry, it should be ["post", post.active? && "active"] On Wed, Mar 5, 2014 at 3:23 PM, Stefan Schüßler wrote: > That array syntax is invalid. > > On Wednesday, March 5, 2014 6:16:01 PM UTC+1, Nicolás Sanguinetti wrote: > >> You can pass Arrays

[Rails-core] module_function and helpers

2014-09-12 Thread Nicolás Sanguinetti
Would core accept a patch that exposes helper methods (that don’t depend on ActionView state) via module_function? The particular use case is that I have other objects that from time to time need access to a single helper method (like, say, #truncate). Including the entire TextHelper seems a b

Re: [Rails-core] module_function and helpers

2014-09-12 Thread Nicolás Sanguinetti
Ok, I’ll take a look at this over the weekend. Thanks, -foca On Fri, Sep 12, 2014 at 1:43 PM, Matthew Draper wrote: > On 12 Sep 2014, at 23:01, Nicolás Sanguinetti > wrote: >> I would much rather do `ActionView::Helpers::TextHelper.truncate(...)` if it >> were possible

Re: [Rails-core] Official support for ActiveSupport::Duration w/o core extensions

2015-03-21 Thread Nicolás Sanguinetti
By requiring "active_support/duration" you’re already forcing core extensions on your users. Take a look at https://github.com/rails/rails/blob/master/activesupport/lib/active_support/duration.rb#L1-L2 (And if you look at those files, they in turn require even more things from core_ext).

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

2015-06-25 Thread Nicolás Sanguinetti
> You need to have a deeper understanding of ruby, and specifically the magic > of the splat (*) operator. I think you missed that the method signature is `def find_by_sql(sql, binds = [])`, and not `def find_by_sql(sql, *binds)`. There’s no splat in the method signature. Before trying t

Re: [Rails-core] Nokogiri adds a lot of weight to ActionView

2015-07-13 Thread Nicolás Sanguinetti
Um, deviating a little from your particular concern (which may or may not be justified), but you really can’t complain about being forced to include a gem multiple times when you’re including action view (and thus active support, I18n, TZInfo, builder, erubis, and a couple more…) *just* to use a

[Rails-core] Re: Rails, Activism and Lack of API

2009-05-20 Thread Nicolás Sanguinetti
On Wed, May 20, 2009 at 2:30 PM, Michael Schuerig wrote: > > On Wednesday 20 May 2009, RSL wrote: >> Merb was always putting out this line about how Rails had no public >> API. I found it laughable at first because >> http://api.rubyonrails.org/ seemed to obviously refute this. However, >> recent

[Rails-core] Re: Opinion about new finder: :unique

2009-08-01 Thread Nicolás Sanguinetti
On Fri, Jul 31, 2009 at 7:43 PM, Michael Koziarski wrote: > >> if the column is unique-constrained, you should use find_by_column (or >> `first` with conditions or scope); >> if the column is not unique, you must use find_all_by_column (or >> alternatives); >> there's no need for an extra method.

[Rails-core] Re: Rails scaffold on 3.0

2009-08-10 Thread Nicolás Sanguinetti
On Mon, Aug 10, 2009 at 9:31 AM, Albert Llop wrote: > On mislav's comment I just have to add that it makes no sense to use > when you can use , and if you want the scaffold to have labels show > bold, then use css. > > Also, personally don't think you need any extra markup at all, but maybe > tha

[Rails-core] Re: Non JavaScript dependent scaffolding solution for record deletion

2009-08-10 Thread Nicolás Sanguinetti
+1 for using button_to instead of link_to. And if submit_tag were to generate a instead of an then +100 :) -foca On Mon, Aug 10, 2009 at 9:37 AM, Mislav Marohnić wrote: > On Mon, Aug 10, 2009 at 13:58, Yehuda Katz wrote: >> >> Are you suggesting that we just put an inline small form

[Rails-core] Re: Long CruiseControl notifications are irritating ...

2009-09-04 Thread Nicolás Sanguinetti
On Fri, Sep 4, 2009 at 8:50 AM, Mislav Marohnić wrote: > On Thu, Sep 3, 2009 at 19:32, Chad Woolley wrote: >> >> 3. Help fix the build :) > > If there are three commits—A, B and C, where A breaks the build and B,C are > unrelated—I'm wondering why should CI send out emails for errors in B and C >

[Rails-core] Re: Long CruiseControl notifications are irritating ...

2009-09-04 Thread Nicolás Sanguinetti
loy > > On Sep 4, 2009, at 2:35 PM, Mike Gunderloy wrote: > >> >> On Sep 4, 2009, at 7:30 AM, Nicolás Sanguinetti wrote: >> >>> "Don't forget the build is broken", thus, spam you with emails until >>> someone drags his ass over and fixes the build

[Rails-core] Re: XSS and Alternate Template Engines

2009-10-11 Thread Nicolás Sanguinetti
2009/10/11 Carlos Júnior : > > Maybe a simple wiki page with a table listing the currently supported > template engines and it's features is enough. One of these features > would obviously be "XSS safe" > > On Mon, 2009-10-12 at 10:14 +1300, Michael Koziarski wrote: >> On Mon, Oct 12, 2009 at 10:0

[Rails-core] Re: Make model.number = "1 234" store 1234 instead of 1?

2009-10-26 Thread Nicolás Sanguinetti
On Mon, Oct 26, 2009 at 7:17 AM, Henrik N wrote: > > Since our users have been complaining about putting "1 234" in a form > and having 1 stored instead of 1234 (because of how to_i/to_f works), > I made a simple monkeypatch to get their expected behavior: > > This is not something that should go

Re: [Rails-core] Re: ActiveSupport for Rails 3

2009-12-15 Thread Nicolás Sanguinetti
On Tue, Dec 15, 2009 at 11:54 PM, Ryan Bigg wrote: > So far, from my understanding, what you've said is that you want to use > some parts of ActiveSupport, but you don't want to use the entire > ActiveSupport "collection". It would be helpful to us if you could name > the parts that you are wantin

Re: [Rails-core] Re: ActiveSupport for Rails 3

2009-12-15 Thread Nicolás Sanguinetti
sed me :) > Yehuda Katz > Developer | Engine Yard > (ph) 718.877.1325 > > > 2009/12/15 Nicolás Sanguinetti >> >> On Tue, Dec 15, 2009 at 11:54 PM, Ryan Bigg >> wrote: >> > So far, from my understanding, what you've said is that you want to

Re: [Rails-core] Re: Proposition: Nested attributes and attr_accessible

2010-01-05 Thread Nicolás Sanguinetti
On Tue, Jan 5, 2010 at 12:19 PM, José Valim wrote: > I think that the main reason to do so by default, is to avoid issues > like people setting nested attributes, but the attribute is protected > and then the assignment never work. > > If this is the case, I would prefer to have a more whiny behav

Re: [Rails-core] Does rails ever automatically bring in a gem?

2010-01-11 Thread Nicolás Sanguinetti
On Tue, Jan 12, 2010 at 12:50 AM, Pito wrote: > I've tried to answer this myself, with my friends and on the rails > list. No joy, > > I got to thinking that something subtle changed between rails 2.3.x > and 2.3.5 which I don't know about. > > I am troubleshooting a weird scenario where a rails a

Re: [Rails-core] Action Mailer new DSL merged

2010-01-25 Thread Nicolás Sanguinetti
Nice. I'm not sure I understand the new API though. You define instance methods but call class methods? Also, what's that magic recipient parameter we never pass in? Why not just define class methods? Eg: class Notifier < ActionMailer::Base  delivers_from("sys...@example.com")   def self.signup

Re: [Rails-core] Patch for bundled gems that depend on application config settings

2010-02-20 Thread Nicolás Sanguinetti
On Sat, Feb 20, 2010 at 2:36 PM, Joe Fiorini wrote: > Would appreciate any thoughts/feedback on my ticket/patch. When are the routes initialized now? Some routes may depend on gems being loaded (like devise, for example) > https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4009-

Re: [Rails-core] Suggestion for Rails partials: associate with a "partial" controller method

2010-03-21 Thread Nicolás Sanguinetti
On Sun, Mar 21, 2010 at 7:23 AM, michael.hasenst...@googlemail.com wrote: > Hi, > > I always found one thing severely missing from Rails' partials: an > equally easy "Rails" way to not just share view templates easily even > across controllers, but also have certain controller code associated > wi

Re: [Rails-core] Introducing Object#self

2010-04-09 Thread Nicolás Sanguinetti
On Fri, Apr 9, 2010 at 10:10 AM, Anuj Dutta wrote: > > > On 9 April 2010 16:56, Joao Carlos wrote: >> >> I just came across a situation where it would be extremely handy to >> have a method that returns the receiver. >> >> Imagine the following example: >> >> filter = %w(with_votes without_votes)

Re: [Rails-core] Re: Introducing Object#self

2010-04-09 Thread Nicolás Sanguinetti
On Fri, Apr 9, 2010 at 4:31 PM, Joao Carlos wrote: > I'll admit mine was a bad example. However, the most common (only?) > use case I could see for it is in fact with #send. > > Your idea for filtering is great, by the way. Instead of send you can use instance_eval. Where you'd do something like

Re: [Rails-core] select method on ActiveRecord::Relation brakes enumeration

2010-05-13 Thread Nicolás Sanguinetti
On Fri, May 14, 2010 at 12:22 AM, Neeraj Singh wrote: > class Brake >  scope :good, where(:quality => 'good') > end > > Brake.all.select &:nil? #=> works fine > Brake.good.select &:nil? #=> FAILS > > Last statement fails because Brake.good.select is returning > ActiveRecord::Relation and not an ar

Re: [Rails-core] don't reload in dev mode

2010-07-03 Thread Nicolás Sanguinetti
On Sat, Jul 3, 2010 at 5:04 PM, Yehuda Katz wrote: > The only way to do this in a pure Ruby way is to poll all the files in a > thread. I'm not sure if this would be more or less performant. We tried this > in Merb and people were annoyed by the constant CPU usage (3-10%) used by > polling the ent

Re: [Rails-core] Re: rails.js etc.

2010-07-05 Thread Nicolás Sanguinetti
Aand this is getting a bit off-topic. If you guys want to fight, that's fine, I'll get some popcorn, a boxing ring, and a bell to signal the rounds. But it's probably better not to do it on this list ;) Cheers On Mon, Jul 5, 2010 at 1:22 PM, Rodrigo Rosenfeld Rosas wrote: > Em 05-07-2010

Re: [Rails-core] Weird Rails3 ActiveRecord results when using count and limit together

2010-07-31 Thread Nicolás Sanguinetti
On Sat, Jul 31, 2010 at 6:08 PM, DBA wrote: > I've implemented the following scope in a rails 3 application: > >    scope :popular, lambda { |l = 5| order('views desc').limit(l) } > > However, it seems that when you attempt to count its records directly > it doesn't apply the scope filters. > > Fo

Re: [Rails-core] Merge db:migrate + db:test:prepare

2010-09-21 Thread Nicolás Sanguinetti
On Tue, Sep 21, 2010 at 11:51 AM, Ryan Bigg wrote: > I had a crazy idea today based off a reader's question[1]. > Why are rake db:migrate and rake db:test:prepare two different tasks? Why > can't we have rake db:migrate migrate both the development and the test > database at the same time? So many

Re: [Rails-core] Merge db:migrate + db:test:prepare

2010-09-21 Thread Nicolás Sanguinetti
On Tue, Sep 21, 2010 at 1:06 PM, Ryan Bigg wrote: > Some test tools such as Cucumber (and I'm sure I've seen it in RSpec but I > cannot reproduce it right now) do not run the migrations before they run the > tests. I think Rails should automatically do it so that when you run the > tests the datab

Re: [Rails-core] Re: Patch for #1812 -- allow default_scope to take a proc

2010-10-19 Thread Nicolás Sanguinetti
Whee :D // sorry for the spammy message, but really, this is fantastic in many levels :D On Tue, Oct 19, 2010 at 10:31 PM, Aaron Patterson wrote: > On Tue, Oct 19, 2010 at 06:06:15PM -0500, Tim Morgan wrote: >> This is great, and I wouldn't have seen the possibilities if you hadn't >> ex

Re: [Rails-core] [patch] extra option for javascript_include_tag (:unique => true) for removing duplicate sources

2010-10-28 Thread Nicolás Sanguinetti
Is there a case where you *wouldn't* want to pass unique: true? Cheers, -foca On Thu, Oct 28, 2010 at 7:56 AM, Christiaan Van den Poel wrote: > Hello, > I've created a small patch wherein I've added an extra parameter to the > 'javascript_include_tag' (:unique => true) which will remove duplicat

Re: [Rails-core] Re: CSRF protection in rails 2.3.11

2011-02-12 Thread Nicolás Sanguinetti
On Sat, Feb 12, 2011 at 6:40 AM, Mathijs wrote: > On Feb 12, 8:05 am, Michael Koziarski wrote: >> CSRF attacks are about using *session* data to perform an action >> without the user's knowledge.  The attack you're describing here, >> which doesn't rely on session data, could also be performed ju

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

2011-02-16 Thread Nicolás Sanguinetti
On Wed, Feb 16, 2011 at 10:15 PM, Ernie Miller wrote: >> (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 tho

Re: [Rails-core] CoffeeScript

2011-03-01 Thread Nicolás Sanguinetti
Lots of technologies are not directly supported by the core team, and yet are widely used by the community, for short and long-term projects. To cite a few: Redis, Haml, MongoDB… The biggest changes in Rails 3 (IMHO) are about ease of extension and increased compatibility with 3rd party tools. Imp

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

2011-04-14 Thread Nicolás Sanguinetti
And actually, `bundle update rails`. You don't want bundler updating all the gems :) On Thu, Apr 14, 2011 at 8:23 PM, Rodrigo Rosenfeld Rosas wrote: > Em 14-04-2011 19:03, Santiago Pastorino escreveu: >> >> ...Simply update your Gemfile to point at the rails version "3.0.7.rc1", >> then `bundle i

Re: [Rails-core] Re: Who is the maintainer for Active Resource? and/or who is interested in working on it?

2011-05-12 Thread Nicolás Sanguinetti
On Thu, May 12, 2011 at 8:23 PM, Ryan BIgg wrote: > I'm working with ActiveResource at the moment and I do find it a bit lacking > personally. Having to implement the find_by_* methods myself is one of my > prime annoyances at the moment. > Perhaps a group of people could get together and work on

Re: [Rails-core] Javascript is now a first-class code citizen - Really?!

2011-08-31 Thread Nicolás Sanguinetti
On Wed, Aug 31, 2011 at 3:10 PM, Wael Nasreddine wrote: > +1 too, jasmine for unit testing and capybara for integration tests Well… make Jasmine optional and I'm a happy camper :) > Regards, > Wael > > -- > Wael Nasreddine > Sent from my iPhone > On Aug 31, 2011, at 19:46, Everton Moreth wr

Re: [Rails-core] Rails 3.1, has_many relationship and new records problem

2011-09-22 Thread Nicolás Sanguinetti
On Thu, Sep 22, 2011 at 11:12 AM, Daro wrote: > Supose I have a simple has_many relationship betwen model_1 and > model_2: > > class Model1 < ActiveRecord::Base >    has_many :models_2 > end > > class Model2 < ActiveRecord::Base >    belongs_to :model_1 > end > > Now, I create an instance of Model

Re: [Rails-core] Why do we have release candidates for patch releases?

2011-11-15 Thread Nicolás Sanguinetti
Rails never quite followed SemVer (call it what you will), though. -foca On Tue, Nov 15, 2011 at 12:01 PM, Prem Sichanugrist wrote: > Again, that is irrelevant. It is a *patch* release, noting should be > breaking. If something break: > 1. We're doing it wrong. That mean some change should *not*

Re: [Rails-core] automatic return from render and redirect

2011-12-19 Thread Nicolás Sanguinetti
On Mon, Dec 19, 2011 at 11:56 PM, Steve Klabnik wrote: > throw/catch for flow control is bad. Indeed it is. It's the one thing in Sinatra I always disliked. If I had to choose, I would go down the path of render/redirect returning a response, so you would do something like `return render :new` o

Re: [Rails-core] Re: Validate absence of

2012-02-27 Thread Nicolás Sanguinetti
On Mon, Feb 27, 2012 at 11:15 AM, Paul Gillard wrote: > Two that spring to mind are: > > validates :auth_code, :absence => true, :unless => :payment_complete? If the auth_code is something that won't be set until you get a response from your payment gateway, then why bother with this? If what you

Re: [Rails-core] Scaffold Generator Woes

2012-03-08 Thread Nicolás Sanguinetti
On Thu, Mar 8, 2012 at 4:38 PM, Geoff Harcourt wrote: > I would be in favor of either of these two options. I imagine extracting and > gem-ifying the controllers would be a hassle, but then the default path for > setting up a new view and controller action would require the user to think > about w

Re: [Rails-core] ActiveResource::Base#dup should take standard new/create args

2012-07-09 Thread Nicolás Sanguinetti
On Mon, Jul 9, 2012 at 4:22 PM, Francesco Rodriguez wrote: > What about initialize_dup? What about it? -f > > El jul 9, 2012 2:11 p.m., "Nicolas Sanguinetti" > escribió: > >> dup doesn't take arguments because in ruby dup doesn't take arguments. It >> wouldn't make sense to break the semantics

Re: [Rails-core] ActiveResource::Base#dup should take standard new/create args

2012-07-10 Thread Nicolás Sanguinetti
On Tue, Jul 10, 2012 at 12:36 PM, Kurt Werle wrote: > On Monday, July 9, 2012 12:10:07 PM UTC-7, Nicolás Sanguinetti wrote: >> >> dup doesn't take arguments because in ruby dup doesn't take arguments. It >> wouldn't make sense to break the semantics of ruby

Re: [Rails-core] rake doc:rails template

2012-07-12 Thread Nicolás Sanguinetti
On Thu, Jul 12, 2012 at 1:38 PM, Xavier Noria wrote: > On Thu, Jul 12, 2012 at 6:29 PM, Rodrigo Rosenfeld Rosas > wrote: > >> This is interesting. A while ago I was asking exactly the opposite: to >> replace api.rubyonrails.org by the version generated with "rake doc:rails". >> >> The reason is t

Re: [Rails-core] Database connection parameters are tied to the filesystem

2012-07-17 Thread Nicolás Sanguinetti
On Tue, Jul 17, 2012 at 9:59 AM, David Rubin wrote: > HI Guys, > > I recently tried VERY hard to override the database configuration bassed on > ENV vars or actual API calls. This task is almost next to impossible. > > I know that the database.yml file is parsed as ERB but that is sane for > simpl

Re: [Rails-core] sti_object.becomes(Parent) unexpectedly mutating the receiver

2012-07-21 Thread Nicolás Sanguinetti
-1 for the merge. +1 for a doc fix where this is more explicit. I've always used x.becomes(Foo) for the side effect (mutating x) instead of for the return value. As I see it, the name _becomes_ clearly states that the receiver is affected. If it was #convert or #cast or something that would reaso

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

2012-08-01 Thread Nicolás Sanguinetti
So things are going to be deprecated by 4.0 and removed in 5.0? Is there anywhere to see the new deprecation policy? Cheers, -foca On Wed, Aug 1, 2012 at 6:05 PM, Rafael Mendonça França wrote: > The correct diff url is > https://github.com/rails/rails/compare/v3.2.7...v3.2.8.rc1 > > Rafael Mendo