Re: [Rails-core] [Feature Request] adding .sample to ActiveRecord

2018-03-27 Thread Rafael Mendonça França
One of the first things to do is check if this feature would not proposed
before. I think you will see that it was already proposed and rejected.

See
https://github.com/rails/rails/pull/16997

On Wed, Mar 28, 2018 at 1:21 AM Regan Ryan  wrote:

> Hi there,
>
> I've never contributed to Rails before, so if I'm doing something wrong,
> please point me in the right direction.
>
> I often do something like `User.all.sample` in Rails console to get a
> random record. This is ok, but it loads every record from the db before
> calling `sample` to get a single record. Some projects have 100k+ users, so
> that takes some time.
>
> *I would like to contribute to Rails by adding a
> `ActiveRecord::Scoping::Named::ClassMethods#sample` method to retrieve a
> single (or more if an argument is specified) random record from the db.*
>
> I've been reading a couple of "how to contribute to rails" guides, one of
> them led me to this group. Is anyone able to guide me from here? How do I
> get approval for this feature?
>
> Cheers,
> Regan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


[Rails-core] [Feature Request] adding .sample to ActiveRecord

2018-03-27 Thread Regan Ryan
Hi there,

I've never contributed to Rails before, so if I'm doing something wrong, 
please point me in the right direction.

I often do something like `User.all.sample` in Rails console to get a 
random record. This is ok, but it loads every record from the db before 
calling `sample` to get a single record. Some projects have 100k+ users, so 
that takes some time.

*I would like to contribute to Rails by adding a 
`ActiveRecord::Scoping::Named::ClassMethods#sample` method to retrieve a 
single (or more if an argument is specified) random record from the db.*

I've been reading a couple of "how to contribute to rails" guides, one of 
them led me to this group. Is anyone able to guide me from here? How do I 
get approval for this feature?

Cheers,
Regan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


[Rails-core] .each on collection on index view created by scaffold

2018-03-27 Thread 'Ben Hamment' via Ruby on Rails: Core
Hi,

I'm new here :D.

I noticed that when you use scaffold it creates an index view and inside 
that index view it uses '.each' on the collection rather than using 
<%= render @cats %>
with a partial _cat.html.erb. I see this as a good opportunity for new 
users of the framework to learn the feature.

I have modified the scaffold generator to create the required partial and 
use the render syntax, should I create a PR or is it oversight on my part?

Related commit:
https://github.com/Otterpocket/rails/commit/5e78d07f1a1353f38950fd6d621ed503970c2016

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


[Rails-core] Re: Feedback on PR?

2018-03-27 Thread Alberto Almagro
I guess this message had it effect as this was already reviewed and merged.

Great PR and great contribution! Thanks Nick!

El lunes, 26 de marzo de 2018, 18:14:12 (UTC+2), Nick Holden escribió:
>
> Hello!
>
> I opened this pull request  a 
> few weeks ago, and I'd love to get some feedback. The Contributing to 
> Ruby on Rails guide 
> 
>  suggested 
> that this mailing list might be a good place to help nudge things along. 
> Let me know if there's any other context I can provide that would be useful.
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.