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

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 to

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).

[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

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 matt...@trebex.net wrote: On 12 Sep 2014, at 23:01, Nicolás Sanguinetti h...@nicolassanguinetti.info wrote: I would much rather do `ActionView::Helpers::TextHelper.truncate

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 sos...@gmail.com wrote: When dealing with conditional class attribute values in

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 sos...@gmail.com 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 to the `class:` option and it will do what you

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

2013-05-22 Thread Nicolás Sanguinetti
? 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? -- Dheeraj Kumar On Wednesday 22 May 2013 at 6:34 AM, Nicolás Sanguinetti wrote

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

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 radudi...@gmail.com wrote: I would like to be able to do the following : UPDATE table SET column1 = column2 + column3 - for the

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] 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

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 david...@gmail.com 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

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 f...@hashref.com wrote: On Thu, Jul 12, 2012 at 6:29 PM, Rodrigo Rosenfeld Rosas rr.ro...@gmail.com wrote: This is interesting. A while ago I was asking exactly the opposite: to replace api.rubyonrails.org by the version generated with rake

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 k...@circlew.org 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 just for this, IMO. I had

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 lrodriguezs...@gmail.com wrote: What about initialize_dup? What about it? -f El jul 9, 2012 2:11 p.m., Nicolas Sanguinetti godf...@gmail.com escribió: dup doesn't take arguments because in ruby dup doesn't take arguments. It wouldn't

Re: [Rails-core] Scaffold Generator Woes

2012-03-08 Thread Nicolás Sanguinetti
On Thu, Mar 8, 2012 at 4:38 PM, Geoff Harcourt geoff.harco...@gmail.com 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

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 paulmgill...@gmail.com 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

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 st...@steveklabnik.com 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

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 sikand...@gmail.com 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

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 wael.nasredd...@gmail.com 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,

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 rr.ro...@gmail.com 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

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.

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 er...@metautonomo.us 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

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 bluescreen...@gmail.com wrote: On Feb 12, 8:05 am, Michael Koziarski mich...@koziarski.com 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

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 christiaan.vandenp...@gmail.com wrote: Hello, I've created a small patch wherein I've added an extra parameter to the 'javascript_include_tag' (:unique =

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 radarliste...@gmail.com 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

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 radarliste...@gmail.com 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

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 rr.ro...@gmail.com

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 wyc...@gmail.com 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

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 neerajdotn...@gmail.com 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

Re: [Rails-core] Introducing Object#self

2010-04-09 Thread Nicolás Sanguinetti
On Fri, Apr 9, 2010 at 10:10 AM, Anuj Dutta dutta.a...@googlemail.com wrote: On 9 April 2010 16:56, Joao Carlos m...@joao-carlos.com 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 =

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 m...@joao-carlos.com 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

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 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

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 j...@faithfulgeek.org 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)

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

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 pitosa...@gmail.com 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

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 jose.va...@gmail.com 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

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 radarliste...@gmail.com 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

[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 hen...@nyh.se 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

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

2009-10-11 Thread Nicolás Sanguinetti
2009/10/11 Carlos Júnior car...@milk-it.net: 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,

[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ćmislav.maroh...@gmail.com wrote: On Thu, Sep 3, 2009 at 19:32, Chad Woolley thewoolley...@gmail.com 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

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

2009-09-04 Thread Nicolás Sanguinetti
, 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 The problem with the spam emails approach is that people will treat them as spam. I don't know what

[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 Llopmrs...@gmail.com wrote: On mislav's comment I just have to add that it makes no sense to use b when you can use label, 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

[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 button instead of an input then +100 :) -foca On Mon, Aug 10, 2009 at 9:37 AM, Mislav Marohnićmislav.maroh...@gmail.com wrote: On Mon, Aug 10, 2009 at 13:58, Yehuda Katz wyc...@gmail.com wrote: Are you

[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 Koziarskimich...@koziarski.com 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

[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 mich...@schuerig.de 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.