<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Khalil Gharbaoui</title>
    <description>The latest articles on DEV Community by Khalil Gharbaoui (@khalilgharbaoui).</description>
    <link>https://dev.to/khalilgharbaoui</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F109665%2F14964ebd-d1b8-406a-8e0a-0607822a4787.jpeg</url>
      <title>DEV Community: Khalil Gharbaoui</title>
      <link>https://dev.to/khalilgharbaoui</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khalilgharbaoui"/>
    <language>en</language>
    <item>
      <title>Answer: A migration to add unique constraint to a combination of columns</title>
      <dc:creator>Khalil Gharbaoui</dc:creator>
      <pubDate>Wed, 04 Dec 2019 09:03:09 +0000</pubDate>
      <link>https://dev.to/khalilgharbaoui/answer-a-migration-to-add-unique-constraint-to-a-combination-of-columns-5h62</link>
      <guid>https://dev.to/khalilgharbaoui/answer-a-migration-to-add-unique-constraint-to-a-combination-of-columns-5h62</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pTF_nE4a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/3370271/a-migration-to-add-unique-constraint-to-a-combination-of-columns/59153244#59153244" rel="noopener noreferrer"&gt;
              &lt;span class="title-flare"&gt;answer&lt;/span&gt; re:  A migration to add unique constraint to a combination of columns
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Dec  3 '19&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/3370271/a-migration-to-add-unique-constraint-to-a-combination-of-columns/59153244#59153244" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5MiFESHx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          4
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rk_a5QFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;For completeness sake, and to avoid confusion here are 3 ways of doing the same thing:&lt;br&gt;
&lt;strong&gt;Adding a named unique constraint to a combination of columns in Rails 5.2+&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let's say we have Locations table that belongs to an advertiser and has column reference_code and you only want 1 reference…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/3370271/a-migration-to-add-unique-constraint-to-a-combination-of-columns/59153244#59153244" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Answer: How do I generate a random 10 digit number in ruby?</title>
      <dc:creator>Khalil Gharbaoui</dc:creator>
      <pubDate>Wed, 02 Oct 2019 17:06:38 +0000</pubDate>
      <link>https://dev.to/khalilgharbaoui/answer-how-do-i-generate-a-random-10-digit-number-in-ruby-5ej</link>
      <guid>https://dev.to/khalilgharbaoui/answer-how-do-i-generate-a-random-10-digit-number-in-ruby-5ej</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/34565/how-do-i-generate-a-random-10-digit-number-in-ruby/55379711#55379711" rel="noopener noreferrer"&gt;
            &lt;span class="title-flare"&gt;answer&lt;/span&gt; re: How do I generate a random 10 digit number in ruby?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Mar 27 '19&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/34565/how-do-i-generate-a-random-10-digit-number-in-ruby/55379711#55379711" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          4
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;&lt;code&gt;('%010d' % rand(0..9999999999)).to_s&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"#{'%010d' % rand(0..9999999999)}"&lt;/code&gt;&lt;/p&gt;

    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/34565/how-do-i-generate-a-random-10-digit-number-in-ruby/55379711#55379711" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
  </channel>
</rss>
