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
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
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
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
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
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
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
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
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).
> 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
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
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
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.
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
+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
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
>
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
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
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
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
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
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
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
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
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-
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
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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*
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
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
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
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
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
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
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
-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
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
53 matches
Mail list logo