Dang it already bought it!
Great book
Really helped me understand docker
The part i am still trying to understand is how to reuse containers properly
I've been trying to get some building automation apps running on it as proof of concept but I am contemplating if docker is even a good fit for something that needs to be always running
Hi,
My new book "Docker for Rails developer" (Pragmatic Programmers) has just launched in early-access beta: https://pragprog.com/book/ridocker/docker-for-rails-developers
It's a light, easy read that will help you get up-to-speed fast. The focus is on practical, real-world usage for developers and will guide you step-by-step. Grab your copy while it's hot... more chapters to follow as soon as they're ready.Not sure? Here's what people are saying about it:This is the book I wish I had when I started delving into Docker.a really enjoyable, clear and informative read[reminds] me of the original DHH Rails book... bravo!When I first saw the title, I might not have been so interested in buying the book given that I'm currently involved in other projects (Elixir! Javascript! Java! Neo4j! etc). However, how wrong I was. This knowledge I can actually export and apply directly to all of my current projects and thus dockerize those environments as well.it has made me rethink the way in which I develop applications.Free prize draw... For your chance to win a free copy, include the following in a tweet "https://pragprog.com/book/ridocker/docker-for-rails-developers #Docker #Rails #RoRTalk @robisenberg" — one winner will be chosen at random.
Cheers,
Rob
p.s. any other help to spread the word would be much appreciated!
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
<script type="text/javascript"> | |
if (window.addthis) { | |
window.addthis = null; | |
window._adr = null; | |
window._atc = null; | |
window._atd = null; | |
window._ate = null; | |
window._atr = null; | |
window._atw = null; | |
} | |
</script> |
ok, you will have a minute to test it...
On Wednesday, April 25, 2018 at 6:26:50 PM UTC-4, Walter Lee Davis wrote:
This would be a Turbolinks problem, very definitely. Turbolinks only refreshes the head of the page when you do a full reload. It's expected that your scripts will be compiled in the Asset Pipeline and will load once. Ever after, the body of the page is silently replaced via Ajax, thus speeding up the loading of your global libraries (by dint of only loading them on the first page load).
Now the problem comes when you have some code in your page body that your script needs to interact with, so you, being a pro, write proper unobtrusive JavaScript that wires up that connection later. Something like:
$(document).on('click', '.lightbox a', function(){
// do something with $(this), which will be the a (link) you clicked on
});
That should work without any modification, because it is lazy-loading the target at the moment the event fires, rather than wiring up the listener on page load.
I suspect that may be what your code is doing, so look through it for something that looks more like:
$(document).ready(function(){
$('.lightbox a').click(function(){
// do something with $(this), which will be the a (link) you clicked on
});
});
If you find that, either rewrite it to the lazy pattern I showed you first, or if it's too complex to untwist, change the $(document).ready bit to this:
$(document).on('load turbolinks:load', function(){
// ...
});
This will hook into the event that fires after Turbolinks refreshes the body of the page, so everything on the screen will be ready to be extended.
Walter
> On Apr 25, 2018, at 11:49 AM, Joe Guerra <jgu...@jginfosys.com> wrote:
>
> I've got some javascript on my rails site ( addthis toolbar & lightbox js ).
>
> They don't always load - I have to hit page refresh at times to get them to load.
>
> Would this be a javascript or rails problem?
>
>
> Thanks,
> Joe
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com .
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .4dbf6afc-43b0-473b-b079- e293972e7f29%40googlegroups. com
> 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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/74555ab5-df20-4314-b8c7-ec6cf269821b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--On 2018-Apr-26, at 13:47 , Abdel Latif <mlotfi2005@gmail.com> wrote:But [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]] has non numerical values too.
On Thursday, April 26, 2018 at 1:05:53 PM UTC-4, Walter Lee Davis wrote:
> On Apr 26, 2018, at 12:12 PM, Abdel Latif <mlotf...@gmail.com> wrote:
>
> Hi,
>
> I found this code for sorting an array :
>
> p ["AB_1020", "AB_950", "AB_50", "1000", "570"].partition{|x| x.to_i.zero? }
> .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}You're missing that String#[] when given a Regexp returns the substring that matches that Regexp.-Rob[1] pry(main)> ["AB_1020", "AB_950", "AB_50",].map {|x| x[/\d+/]}=> ["1020", "950", "50"][2] pry(main)> ["AB_1020", "AB_950", "AB_50",].map {|x| x[/\d+/]}.sort=> ["1020", "50", "950"][3] pry(main)> ["AB_1020", "AB_950", "AB_50",].map {|x| x[/\d+/]}.sort.reverse=> ["950", "50", "1020"][4] pry(main)> ["AB_1020", "AB_950", "AB_50",].map {|x| x[/\d+/].to_i}.sort.reverse=> [1020, 950, 50][5] pry(main)> ["AB_1020", "AB_950", "AB_50",].sort_by {|x| x[/\d+/].to_i}=> ["AB_50", "AB_950", "AB_1020"]> ouptut
>
> #⇒ ["AB_50", "AB_950", "AB_1020", "570", "1000"]
>
>
> I know that .partition{|x| x.to_i.zero? } will create an array of arrays :
> [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]]
>
>
> But this part .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
flat_map: https://apidock.com/ruby/Enumerable/flat_map
Then that passes a block, which acts on each member of the Enumerable that called flat_map. That block sorts by the numerical value of x, then reverses.
Does that help?
Walter
>
> I could understand it.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c8e2dc7d- .8501-4df3-b19c-917ebded457f% 40googlegroups.com
> 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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com .
To post to this group, send email to rubyonrails-talk@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .f6fa4cc4-37b2-4828-ba1c- f9ac0d780221%40googlegroups. com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/ .C3hSRwet4tY/unsubscribe
To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe@googlegroups.com .
To post to this group, send email to rubyonrails-talk@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .F584BA16-90B8-40DD-8C04- A92CBF336241%40gmail.com
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPzaUfPOPEdR-WOqX%3D_ugk%2BjB1BDRtgv3i20z1Xfji9LiDKuUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
> On Apr 30, 2018, at 5:07 AM, fugee ohu <fugee279@gmail.com> wrote:
>
> I've been putting options for select lists in my models but I haven't been able to do this with option/value pairs Anyone know how? The code below doesn't work
>
> DURATION_TYPES = [['7 days', '7' ],['14 days', '14'], ['21 days','21'], ['30 days','30']]
> validates :duration, inclusion: { in: DURATION_TYPES }
>
>
When this validator runs, what is it comparing? The label or the value? You are passing a combination of the two into your validator and expecting it to guess. You could try either using a hash for the data structure, and being explicit about what you want it to compare:
DURATION_TYPES = {'7 days' => 7, '14 days' => 14 ... }
validates :duration, inclusion: { in: DURATION_TYPES.values }
or you could extract just the second value out each pair (using your existing nested array):
validates :duration, inclusion: { in: DURATION_TYPES.map(&:last) }
Please google "Ruby symbol to Proc" to better understand how that last one works. If you use the first approach, then you will need to change the way you access the constant's values in your select list constructor.
Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c04d58fa-0e5b-42f8-8d80-20375f07f98c%40googlegroups.com.
> 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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/75447E69-9828-4F9E-9E6E-A001CFE23FA3%40wdstudio.com.
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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c04d58fa-0e5b-42f8-8d80-20375f07f98c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
On Wednesday, April 25, 2018 at 3:57:06 AM UTC-4, Colin Law wrote:ColinCan I ask you a question Fugee? First allow me to make a point. You have been posting here for over three years I think. When someone starts using Rails then obviously they may well be asking a number of questions and that is what this list is for. Typically after a few months experience I would expect to see members starting to answer questions from those less experienced than themselves as well as still asking questions about more complex issues. After a year I would expect the contributions to be mostly helping others with only occasional questions of their own, and after three years I would expect to see 99% of the contributions being helping others and 1% asking questions. That is how a list like this survives, newbies and less experienced members getting help from more experienced members, and over a period of time as they gain experience themselves they repay the help from the community by providing help themselves.So my question is, in the last year how many times have you provided help to others here and how many times have you asked for help for yourself?On 25 April 2018 at 08:38, fugee ohu <fuge...@gmail.com> wrote:I see on craigslist or ebay we can add pictures before submitting a post or auction On ebay you can't submit an auction without at least one image So how would I let my users add images to something that hasn't been saved yet?--tag: steps
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/19a0fb36- .7871-4203-8e5e-670ced7c3a7b% 40googlegroups.com
For more options, visit https://groups.google.com/d/optout .
There just aren't enough newb questions for me to answer Most questions are either over my head or just not things I've already done
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com .
To post to this group, send email to rubyonrails-talk@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .c2c63ace-a88a-4f10-911b- 2b09622ca3dd%40googlegroups. com
For more options, visit https://groups.google.com/d/optout .
Cell 027 3089 169
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKajAboxKqAYiGjEbsfwoVR2ogqZ41%3DUnP-ANTPtA7jRzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On Wednesday, April 25, 2018 at 3:57:06 AM UTC-4, Colin Law wrote:
ColinCan I ask you a question Fugee? First allow me to make a point. You have been posting here for over three years I think. When someone starts using Rails then obviously they may well be asking a number of questions and that is what this list is for. Typically after a few months experience I would expect to see members starting to answer questions from those less experienced than themselves as well as still asking questions about more complex issues. After a year I would expect the contributions to be mostly helping others with only occasional questions of their own, and after three years I would expect to see 99% of the contributions being helping others and 1% asking questions. That is how a list like this survives, newbies and less experienced members getting help from more experienced members, and over a period of time as they gain experience themselves they repay the help from the community by providing help themselves.So my question is, in the last year how many times have you provided help to others here and how many times have you asked for help for yourself?On 25 April 2018 at 08:38, fugee ohu <fuge...@gmail.com> wrote:I see on craigslist or ebay we can add pictures before submitting a post or auction On ebay you can't submit an auction without at least one image So how would I let my users add images to something that hasn't been saved yet?--tag: steps
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .19a0fb36-7871-4203-8e5e- 670ced7c3a7b%40googlegroups. com
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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c2c63ace-a88a-4f10-911b-2b09622ca3dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Wednesday, April 25, 2018 at 3:57:06 AM UTC-4, Colin Law wrote:
ColinCan I ask you a question Fugee? First allow me to make a point. You have been posting here for over three years I think. When someone starts using Rails then obviously they may well be asking a number of questions and that is what this list is for. Typically after a few months experience I would expect to see members starting to answer questions from those less experienced than themselves as well as still asking questions about more complex issues. After a year I would expect the contributions to be mostly helping others with only occasional questions of their own, and after three years I would expect to see 99% of the contributions being helping others and 1% asking questions. That is how a list like this survives, newbies and less experienced members getting help from more experienced members, and over a period of time as they gain experience themselves they repay the help from the community by providing help themselves.So my question is, in the last year how many times have you provided help to others here and how many times have you asked for help for yourself?On 25 April 2018 at 08:38, fugee ohu <fuge...@gmail.com> wrote:I see on craigslist or ebay we can add pictures before submitting a post or auction On ebay you can't submit an auction without at least one image So how would I let my users add images to something that hasn't been saved yet?--tag: steps
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .19a0fb36-7871-4203-8e5e- 670ced7c3a7b%40googlegroups. com
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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4de60cc5-cf5f-4d92-8c0f-01812720c483%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Wednesday, April 25, 2018 at 3:57:06 AM UTC-4, Colin Law wrote:
ColinCan I ask you a question Fugee? First allow me to make a point. You have been posting here for over three years I think. When someone starts using Rails then obviously they may well be asking a number of questions and that is what this list is for. Typically after a few months experience I would expect to see members starting to answer questions from those less experienced than themselves as well as still asking questions about more complex issues. After a year I would expect the contributions to be mostly helping others with only occasional questions of their own, and after three years I would expect to see 99% of the contributions being helping others and 1% asking questions. That is how a list like this survives, newbies and less experienced members getting help from more experienced members, and over a period of time as they gain experience themselves they repay the help from the community by providing help themselves.So my question is, in the last year how many times have you provided help to others here and how many times have you asked for help for yourself?On 25 April 2018 at 08:38, fugee ohu <fuge...@gmail.com> wrote:I see on craigslist or ebay we can add pictures before submitting a post or auction On ebay you can't submit an auction without at least one image So how would I let my users add images to something that hasn't been saved yet?--tag: steps
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .19a0fb36-7871-4203-8e5e- 670ced7c3a7b%40googlegroups. com
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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d1763172-b407-409e-aa6e-d8484d2d8112%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
DURATION_TYPES = [['7 days', 7 ],['14 days', 14], ['21 days',21], ['30 days',30]]
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3c500355-d992-4867-a215-4f3d6b5bd908%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
But this part .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
1) /d+/
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAAwHHQica6sEZ-OPOnbGUyG_MGOPKW21iOd%3D_HxacnSmeTeRCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On 2018-Apr-26, at 13:47 , Abdel Latif <mlotfi2005@gmail.com> wrote:But [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]] has non numerical values too.
On Thursday, April 26, 2018 at 1:05:53 PM UTC-4, Walter Lee Davis wrote:
> On Apr 26, 2018, at 12:12 PM, Abdel Latif <mlotf...@gmail.com> wrote:
>
> Hi,
>
> I found this code for sorting an array :
>
> p ["AB_1020", "AB_950", "AB_50", "1000", "570"].partition{|x| x.to_i.zero? }
> .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
> ouptut
>
> #⇒ ["AB_50", "AB_950", "AB_1020", "570", "1000"]
>
>
> I know that .partition{|x| x.to_i.zero? } will create an array of arrays :
> [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]]
>
>
> But this part .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
flat_map: https://apidock.com/ruby/Enumerable/flat_map
Then that passes a block, which acts on each member of the Enumerable that called flat_map. That block sorts by the numerical value of x, then reverses.
Does that help?
Walter
>
> I could understand it.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com .
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .c8e2dc7d-8501-4df3-b19c- 917ebded457f%40googlegroups. com
> 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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f6fa4cc4-37b2-4828-ba1c-f9ac0d780221%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thursday, April 26, 2018 at 1:05:53 PM UTC-4, Walter Lee Davis wrote:
> On Apr 26, 2018, at 12:12 PM, Abdel Latif <mlotf...@gmail.com> wrote:
>
> Hi,
>
> I found this code for sorting an array :
>
> p ["AB_1020", "AB_950", "AB_50", "1000", "570"].partition{|x| x.to_i.zero? }
> .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
> ouptut
>
> #⇒ ["AB_50", "AB_950", "AB_1020", "570", "1000"]
>
>
> I know that .partition{|x| x.to_i.zero? } will create an array of arrays :
> [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]]
>
>
> But this part .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
flat_map: https://apidock.com/ruby/Enumerable/flat_map
Then that passes a block, which acts on each member of the Enumerable that called flat_map. That block sorts by the numerical value of x, then reverses.
Does that help?
Walter
>
> I could understand it.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegroups.com .
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .c8e2dc7d-8501-4df3-b19c- 917ebded457f%40googlegroups. com
> 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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f6fa4cc4-37b2-4828-ba1c-f9ac0d780221%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
> On Apr 26, 2018, at 12:12 PM, Abdel Latif <mlotfi2005@gmail.com> wrote:
>
> Hi,
>
> I found this code for sorting an array :
>
> p ["AB_1020", "AB_950", "AB_50", "1000", "570"].partition{|x| x.to_i.zero? }
> .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
> ouptut
>
> #⇒ ["AB_50", "AB_950", "AB_1020", "570", "1000"]
>
>
> I know that .partition{|x| x.to_i.zero? } will create an array of arrays :
> [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]]
>
>
> But this part .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
flat_map: https://apidock.com/ruby/Enumerable/flat_map
Then that passes a block, which acts on each member of the Enumerable that called flat_map. That block sorts by the numerical value of x, then reverses.
Does that help?
Walter
>
> I could understand it.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c8e2dc7d-8501-4df3-b19c-917ebded457f%40googlegroups.com.
> 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: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/F80F3086-EFC6-4E2F-99E8-07C60AAD479D%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
p ["AB_1020", "AB_950", "AB_50", "1000", "570"].partition{|x| x.to_i.zero? }
.flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse}
ouptut
#⇒ ["AB_50", "AB_950", "AB_1020", "570", "1000"]
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c8e2dc7d-8501-4df3-b19c-917ebded457f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.