[Rails-core] [Feature request] has_many option to generate additionnal has_many for each given scope.

2017-03-21 Thread Julien Grillot
Hi there!

I am writing a new option for `has_many` associations. It generates 
additionnal has_many for each given association scope.

# Before
has_many :posts
has_many :published_posts, -> { published }, class_name: "Post"

# After
has_many :posts, new_option: [:published]


*Why*
In my rails projects, I really often write a lot of `has_many` variations 
to be able to use fine-grained preload. Eg: 
`Author.all.preload(:published_post).each do [...]`.

It would be handful to have syntaxic sugar to shorten all theses `has_many`

*What I've done*
https://github.com/Bahanix/rails/commit/15ec54d175a8936e8f1017a77a160760c8fb92a2
I am very unsure about my `compose` option name (I am not a native english 
speaker).
Does the feature seems useful to you / relevant for an ActiveRecord PR?

Thank you for reading :)
Julien Grillot

-- 
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: Question about rc1 in RAILS_VERSION file?

2017-03-21 Thread Al
Oh - OK, Thanks

On Monday, March 20, 2017 at 9:23:03 PM UTC-4, Al wrote:
>
> Just saw rc1 for Rails. Have a question.
>
> Does https://github.com/rails/rails/blob/master/RAILS_VERSION in master 
> (edge rails) need to be "5.1.0.rc1"?
>
> 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.


Re: [Rails-core] Collection caching: render to strings

2017-03-21 Thread Gleb Mazovetskiy
If you mean whether cache_collection_render is usable, I think it would be
but it is currently private!

The implementation I've linked to above does use PartialRenderer, and
effectively reimplements cache_collection_render using only public APIs.

On Tue, Mar 21, 2017 at 6:45 PM Kasper Timm Hansen  wrote:

> Right, it’s joined with the spacer template. Maybe that’s usable?
>
>
> https://github.com/rails/rails/blob/9c0a82d5766c2c01f1e75eb5c70c65f28ec6a665/actionview/lib/action_view/renderer/partial_renderer.rb#L326
>
> Den 20. mar. 2017 kl. 21.44 skrev Gleb Mazovetskiy :
>
> No, a collection cache render returns a single string.
>
> On Mon, 20 Mar 2017, 19:15 Kasper Timm Hansen,  wrote:
>
> Been a while since I’ve last worked with that code but doesn’t a
> collection cache render return a collection of rendered HTML strings?
>
> I think you might be able to stitch the objects and their rendered HTML
> together like this:
>
> @posts.zip(render(partial: ’posts/post’, collection: @posts, cached:
> true))
>
> Though overall, I don’t think we’re going to change the interface here.
> Thanks! :)
>
> Den 5. mar. 2017 kl. 10.06 skrev Gleb Mazovetskiy :
>
> Here is an example implementation:
> https://github.com/thredded/thredded/pull/536/files#diff-00110786c7c8a611fd05432b7fb15270
>
>
> --
>
> 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.
>
>
> --
> Kasper
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ruby on Rails: Core" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/rubyonrails-core/Cx0GXz_k7Dc/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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.
>
>
> --
> Kasper
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ruby on Rails: Core" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/rubyonrails-core/Cx0GXz_k7Dc/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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.


Re: [Rails-core] Collection caching: render to strings

2017-03-21 Thread Kasper Timm Hansen
Right, it’s joined with the spacer template. Maybe that’s usable?

https://github.com/rails/rails/blob/9c0a82d5766c2c01f1e75eb5c70c65f28ec6a665/actionview/lib/action_view/renderer/partial_renderer.rb#L326
 

> Den 20. mar. 2017 kl. 21.44 skrev Gleb Mazovetskiy :
> 
> No, a collection cache render returns a single string.
> 
> 
> On Mon, 20 Mar 2017, 19:15 Kasper Timm Hansen,  > wrote:
> Been a while since I’ve last worked with that code but doesn’t a collection 
> cache render return a collection of rendered HTML strings?
> 
> I think you might be able to stitch the objects and their rendered HTML 
> together like this:
> 
> @posts.zip(render(partial: ’posts/post’, collection: @posts, cached: 
> true))
> 
> Though overall, I don’t think we’re going to change the interface here. 
> Thanks! :)
> 
> 
>> Den 5. mar. 2017 kl. 10.06 skrev Gleb Mazovetskiy > >:
>> 
> 
>> Here is an example implementation: 
>> https://github.com/thredded/thredded/pull/536/files#diff-00110786c7c8a611fd05432b7fb15270
>>  
>> 
>> 
>> 
>> -- 
> 
>> 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 
>> .
> 
> 
> --
> Kasper
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Ruby on Rails: Core" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/rubyonrails-core/Cx0GXz_k7Dc/unsubscribe 
> .
> To unsubscribe from this group and all its topics, 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 
> .

--
Kasper

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


Re: [Rails-core] Question about rc1 in RAILS_VERSION file?

2017-03-21 Thread Rafael Mendonça França
It needs to be 5.2.0.alpha. We are working on this change.

On Mon, Mar 20, 2017 at 9:23 PM Al  wrote:

> Just saw rc1 for Rails. Have a question.
>
> Does https://github.com/rails/rails/blob/master/RAILS_VERSION in master
> (edge rails) need to be "5.1.0.rc1"?
>
> 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.
>

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