<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sis Ccr on Medium]]></title>
        <description><![CDATA[Stories by Sis Ccr on Medium]]></description>
        <link>https://medium.com/@sisccr?source=rss-1b4232e6708c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*NFl9bqaR3z4UPOa-.</url>
            <title>Stories by Sis Ccr on Medium</title>
            <link>https://medium.com/@sisccr?source=rss-1b4232e6708c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:41:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sisccr/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rant on rails (PG install error)]]></title>
            <link>https://sisccr.medium.com/rant-on-rails-67dee4e70e2b?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/67dee4e70e2b</guid>
            <category><![CDATA[error]]></category>
            <category><![CDATA[bundle]]></category>
            <category><![CDATA[gem]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Mon, 27 May 2024 00:26:46 GMT</pubDate>
            <atom:updated>2024-06-02T04:48:58.967Z</atom:updated>
            <content:encoded><![CDATA[<p>There are some things that always gets in the way. This post is a absolute rant but with a solution.</p><p>Recently bundler was failing on my mac. It just can’t install <strong>gem pg.</strong> <br>tried a lots of googling and copy pasting without knowing what it does. Seriously sometimes things just gets irritating because I just dont know how to solve it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lfj1pphDcg5y_OPezZS4Kw.png" /></figure><p>I want to work on something else, and found I am using sqlite. I changed the to pg gem and now it start to complain. Honestly rails is good, But to the configuration part is the most irritating for new people. Sometimes I just miss the plain old .exe file where everything was bundled, but then also they had dll file missing error :D .</p><p>Anyway, I have a postgress app. So when Pg install fails, one of the most suggested way is to build the gem using pg_config</p><pre>gem install pg - - with-pg-config=/Applications/Postgres.app/Contents/Versions/9/bin/pg_config</pre><p>I tried this but it always failed. Later, after a long time :( I realised probably the version is not matching. So I try to find my version installed for postgress app with this command.</p><pre>/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config --version</pre><p>And the dust just settles here. I had the <strong>PostgreSQL 13.0 </strong>installed. so I reran the command</p><pre>gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/13/bin/pg_config</pre><p>This time it is installed. Finally I can write some ruby code :).</p><p>Update: <br>we can add pg_config in zshrc, <br>open zshrc file, <strong>vi ~/.zshrc</strong> and paste following</p><pre>export PG_CONFIG=/Applications/Postgres.app/Contents/Versions/16.3/bin/pg_config</pre><p>save and exit. then</p><p><strong>source ~/.zshrc</strong></p><p>now this will work</p><pre>gem install pg</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67dee4e70e2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi Select Dropdown in rails using daisyUI]]></title>
            <link>https://sisccr.medium.com/multi-select-dropdown-in-rails-using-daisyui-99d4c41039bc?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/99d4c41039bc</guid>
            <category><![CDATA[multiselect-dropdown]]></category>
            <category><![CDATA[hotwire-rails]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[daisyui]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Sun, 19 May 2024 01:19:49 GMT</pubDate>
            <atom:updated>2024-05-19T01:19:49.021Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I integrate <a href="https://daisyui.com/components/dropdown/">daisyUI dropdown</a> component in rails. This was my first time and aslo since rails and js are not my primary language it was hard to figure out how to do it. Most of the tutorials are focused on the drop down using the Select and options.</p><p>I am using viewComponent in this but its optional. The concept can be easily transferred to any rails partial.</p><p>here is the picture of what I am trying to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*pEu45ZF3LwVfD8NXN_N8IQ.png" /></figure><p>Tha main Dropdown Component is, I am also using stimulus controller to work with js.</p><pre>&lt;div data-controller=&quot;multi-select&quot;&gt;<br>  &lt;details class=&quot;dropdown&quot;&gt;<br>    &lt;summary class=&quot;btn m-1&quot;&gt;&lt;%= @title %&gt;&lt;/summary&gt;<br>    &lt;ul class=&quot;dropdown-content menu z-[1] w-52 rounded-box bg-base-100 p-2 shadow&quot;&gt;<br>      &lt;% @options.each do |option| %&gt;<br>        &lt;li&gt;<br>          &lt;label class=&quot;label cursor-pointer&quot;&gt;<br>            &lt;input data-action=&quot;change-&gt;multi-select#selectItem&quot; data-value = &lt;%= option.to_json %&gt;  type=&quot;checkbox&quot; class=&quot;checkbox-accent checkbox&quot; /&gt;<br>            &lt;span class=&quot;label-text mx-5&quot;&gt;&lt;%= option[:value] %&gt;&lt;/span&gt;<br>          &lt;/label&gt;<br>        &lt;/li&gt;<br>      &lt;% end %&gt;<br>    &lt;/ul&gt;<br>  &lt;/details&gt;<br>  &lt;%= content %&gt;<br>&lt;/div&gt;</pre><p>The<em> &lt;%= content %&gt;</em> is used to render the <strong>hidden_field</strong> in rails form. ViewComponent will render any html that is passed to its block in the content. As shown in picture I have checkbox for each items. When we change the value for checkbox <strong><em>data-action=”change-&gt;multi-select#selectItem”,</em></strong> selectItem function will be called in the stimulus controller</p><p>heres is the actual form element in the _form partial</p><pre>   &lt;div class=&quot;my-5&quot;&gt;<br>    &lt;%= form.label :size_id %&gt;<br>    &lt;%#= form.collection_select :size_ids, Size.order(:size), :id, :size, prompt: true, multiple: true, class: &quot;block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full&quot; %&gt;<br>    &lt;%= render(MultiSelect::MultiSelectComponent.new(title: &quot;Select Size&quot;, options: Size.order(:size).map{|s| {id: s.id, value: s.size}})) do %&gt;    <br>        &lt;%if admin_product.sizes.present?%&gt; <br>          &lt;span&gt;&lt;strong&gt;Selected Size:&lt;/strong&gt; &lt;%= admin_product.sizes.map(&amp;:size).join(&quot;, &quot;) %&gt;&lt;/span&gt;<br>        &lt;%end%&gt;<br>        &lt;div data-multi-select-target=&quot;hiddenField&quot;&gt;&lt;/div&gt;<br>    &lt;% end %&gt;<br>  &lt;/div&gt;</pre><p>remember the <em>&lt;%= content %&gt;</em> in the component, <strong><em>&lt;div data-multi-select-target=”hiddenField”&gt;&lt;/div&gt;</em></strong> this will get render there.</p><p>heres my stimulus controller</p><pre>import { Controller } from &quot;@hotwired/stimulus&quot;;<br><br>export default class extends Controller {<br>  static targets = [&quot;hiddenField&quot;]<br><br>  connect() {<br>    console.log(&quot;Hello, Multiselect!&quot;, this.element);<br>    this.selectedIds = new Set();<br>  }<br><br>  selectItem(event) {<br>    console.log(&quot;select item&quot;)<br>    const checkbox = event.target;<br>    const id = JSON.parse(checkbox.dataset.value).id<br>    if (checkbox.checked) {<br>      this.selectedIds.add(id);<br>    } else {<br>      this.selectedIds.delete(id);<br>    }<br>    this.updateHiddenField();<br>  }<br><br>  updateHiddenField() {<br>    console.log(this.selectedIds);<br>    // Clear existing hidden inputs<br>    this.hiddenFieldTarget.innerHTML = &#39;&#39;;<br>    <br>    // Create a hidden input for each selected ID<br>    this.selectedIds.forEach(id =&gt; {<br>      const hiddenInput = document.createElement(&#39;input&#39;);<br>      hiddenInput.type = &#39;hidden&#39;;<br>      hiddenInput.name = &#39;product[size_ids][]&#39;;<br>      hiddenInput.value = id;<br>      this.hiddenFieldTarget.appendChild(hiddenInput);<br>    });<br>  }<br>}</pre><p>whenever we are changing the value of the checkbox, we are creating a new html input element and appending it the the div that had the hidden target. Notice the name of the input <strong><em>‘product[size_ids][]’</em></strong>, this is because</p><p>the parameter<strong><em> size_ids: []</em></strong> will be nested under the “product” key</p><pre>params.require(:product).permit(:name, :details, :const_price, :sale_price, :category_id, :active, images: [], size_ids: [])</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99d4c41039bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TypeError: Importmap issue in safari]]></title>
            <link>https://sisccr.medium.com/typeerror-importmap-issue-in-safari-9ba8060a1df6?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ba8060a1df6</guid>
            <category><![CDATA[importmap]]></category>
            <category><![CDATA[console-log]]></category>
            <category><![CDATA[rails-7]]></category>
            <category><![CDATA[typeerror]]></category>
            <category><![CDATA[stimulus]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Wed, 07 Feb 2024 22:45:40 GMT</pubDate>
            <atom:updated>2024-02-07T22:45:40.228Z</atom:updated>
            <content:encoded><![CDATA[<p>I had strange issue. I have a basic rails 7 app, using default importmap. I had small stimulus controller that basicaly changed the text of the link_to tag when the page is loaded.</p><p>All was working fine in chrome. But as I tested it on safari, it does not work. and there is strange error in console</p><pre>TypeError: Module specifier, &#39;application&#39; does not start with &quot;/&quot;, &quot;./&quot;, or &quot;../&quot;. Referenced from http://localhost:3000/So the root problem turns out to be safari version. I am using importmap-rails version  (2.0.1), and safari version was 16.3. I found out that</pre><p><strong>Importmaps 2.x are only supported from Safari 16.4 onwart.</strong></p><p>so either I</p><ol><li>downgrade the importmap to vs 1.x or</li><li>update safari (i.e mac os ) or</li><li>include the es-module-shims myself (importmap-rails 1.x includes the shim, 2.x dropped it)</li></ol><p>I looked at <a href="https://github.com/guybedford/es-module-shims">es-module-shims github page</a></p><p>and implemented following script.</p><pre>    &lt;script async src=&quot;https://ga.jspm.io/npm:es-module-shims@1.8.2/dist/es-module-shims.js&quot;&gt;&lt;/script&gt;<br>     &lt;script type=&quot;importmap&quot;&gt;<br>     {<br>       &quot;imports&quot;: {<br>         &quot;react&quot;: &quot;https://ga.jspm.io/npm:react@18.0.0-rc.0/index.js&quot;<br>       },<br>       &quot;scopes&quot;: {<br>         &quot;https://ga.jspm.io/npm:react@18.0.0-rc.0/&quot;: {<br>           &quot;object-assign&quot;: &quot;https://ga.jspm.io/npm:object-assign@4.1.1/index.js&quot;<br>         }<br>       }<br>     }<br>     &lt;/script&gt;<br>   &lt;/body&gt;<br> &lt;/html&gt;</pre><p>and then the error is still there, but the stimulus controller is now working fine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ba8060a1df6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bootstrap with Rails 7 with importmap]]></title>
            <link>https://sisccr.medium.com/bootstrap-with-rails-7-with-importmap-bd5b8fb3ada1?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd5b8fb3ada1</guid>
            <category><![CDATA[ruby-on-rails-7]]></category>
            <category><![CDATA[rails-7]]></category>
            <category><![CDATA[css3]]></category>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[importmap]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 04:13:01 GMT</pubDate>
            <atom:updated>2024-01-17T17:41:34.360Z</atom:updated>
            <content:encoded><![CDATA[<p>Bootstrap with Rails 7 with importmap</p><p>Probably lot of us are banging my head to install bootstrap with rails 7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*be083PHn30tRMNQYV9VThQ.png" /></figure><ol><li>I have a app created fresh with Rails 7.1.2.<br><strong>rails new my_app</strong></li></ol><p>2. Add gems</p><pre>gem &quot;sassc-rails&quot;<br>gem &quot;bootstrap&quot;</pre><p>3. in app/assets/stylesheets/application.css, rename it to .scss extension</p><p>4. then add following, delete everything</p><pre><br>@import &quot;bootstrap&quot;;</pre><p>5. in config/initializers/assets.rb, add this</p><pre><br>Rails.application.config.assets.precompile += %w( bootstrap.min.js popper.js )</pre><p>6. pin the compiled asset in config/importmap.rb:</p><pre>pin &quot;popper&quot;, to: &#39;popper.js&#39;, preload: true<br>pin &quot;bootstrap&quot;, to: &#39;bootstrap.min.js&#39;, preload: true</pre><p>7. app/javascript/application.js, add</p><pre>import &quot;popper&quot;<br>import &quot;bootstrap&quot;</pre><p>and thats it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd5b8fb3ada1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[121. Best Time to Buy and Sell Stock]]></title>
            <link>https://sisccr.medium.com/121-best-time-to-buy-and-sell-stock-bdd8fa48ce15?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdd8fa48ce15</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Tue, 20 Sep 2022 01:40:05 GMT</pubDate>
            <atom:updated>2022-09-20T15:20:29.896Z</atom:updated>
            <content:encoded><![CDATA[<p>I think I can invest in shares, because now I know how to find the maximum profit :P</p><p>There is to things we need to track.</p><ol><li>buying price</li><li>maximum profit</li></ol><p>We need buying price as low as possible, so first we assume a large number for it. Once we began iteration, we will check if current price is lower than buying price? if its lower we replace our assumed Buying price with the lowest price.</p><p>Once we have our buying price, we need to calculate profit. Initially we assume 0 profit. The profit is the amount remaining by substracting the buying price from current price. In line 13 we calculate current profit. If this profit is greater than we had in maxProfit, we assigned maxProfit with current profit. As we iterate, once we find the lowest buying price it will not change. And the logic will focus on finding the maximum profit. The time complexity for this is O(n) since we iterate through every element only once.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee05fdd5dc198f3567491f97747b6a95/href">https://medium.com/media/ee05fdd5dc198f3567491f97747b6a95/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdd8fa48ce15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1. Two Sum]]></title>
            <link>https://sisccr.medium.com/1-two-sum-949f720b0816?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/949f720b0816</guid>
            <category><![CDATA[leetcode-easy]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[two-sum]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Thu, 18 Aug 2022 20:33:47 GMT</pubDate>
            <atom:updated>2022-08-18T20:33:47.862Z</atom:updated>
            <content:encoded><![CDATA[<p>Going through the leetcode</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63d530a9681a34b897728560489ea421/href">https://medium.com/media/63d530a9681a34b897728560489ea421/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=949f720b0816" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy Pagination with Vapor 4]]></title>
            <link>https://sisccr.medium.com/easy-pagination-with-vapor-4-38edc3f11f4b?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/38edc3f11f4b</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[server-side-swift]]></category>
            <category><![CDATA[vapor]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Fri, 08 Oct 2021 09:30:10 GMT</pubDate>
            <atom:updated>2021-10-08T09:30:10.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*CsKlbhIxEhTQE7__u-ORww.png" /><figcaption>pagination</figcaption></figure><p>Pagination in Vapor was very easy as vapor provides the paginate(for: request) function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9da27b29281e4fe08b5da6fa84f6f8f/href">https://medium.com/media/c9da27b29281e4fe08b5da6fa84f6f8f/href</a></iframe><p>we call call this from client side as:</p><p><a href="http://{{baseurl}}/rooms?type=house&amp;lowerPrice=0&amp;upperPrice=10000&amp;page=2&amp;per=2">http://{{baseurl}}/rooms?type=house&amp;lowerPrice=0&amp;upperPrice=10000&amp;page=2&amp;per=2</a></p><p>this will return the json with metadata describing the pages attributes.</p><pre>{<br>    &quot;data&quot;: {<br>        &quot;items&quot;: [<br>            {<br>              ...<br>                &quot;preference&quot;: &quot;family&quot;,<br>                &quot;phone&quot;: &quot;9849192759&quot;,<br>                &quot;lat&quot;: 27.717199999999998,<br>              ...<br>            }<br>        ],<br>        &quot;metadata&quot;: {<br>            &quot;per&quot;: 2,<br>            &quot;total&quot;: 4,<br>            &quot;page&quot;: 2<br>        }<br>    }<br>}</pre><p>This was easier than I thought.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38edc3f11f4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multiple file upload with vapor 4]]></title>
            <link>https://sisccr.medium.com/multiple-file-upload-with-vapor-4-fcedc0c2b7d3?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcedc0c2b7d3</guid>
            <category><![CDATA[upload]]></category>
            <category><![CDATA[vaporswift]]></category>
            <category><![CDATA[multiple-file-upload]]></category>
            <category><![CDATA[vapor]]></category>
            <category><![CDATA[server-side-swift]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Mon, 04 Oct 2021 05:39:45 GMT</pubDate>
            <atom:updated>2021-10-04T05:45:21.318Z</atom:updated>
            <content:encoded><![CDATA[<p>Most of the application needs image uploading. But I did not find many documented resources. Hence I would like to share my experiences with you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJXnNZZZAiYcyhjJJ6gFRw.png" /></figure><p>I have a Appartment Rental application that needs to send images along with other attributes in multipart form data.</p><p>I am using postgres as database. And vapor has fluent as its orm.</p><p>My Room Model is very simple but huge due to the number of attributes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d626f57661723378150fd4ad37db3908/href">https://medium.com/media/d626f57661723378150fd4ad37db3908/href</a></iframe><p>Room Model also has Input and Output structs. Input is the request coming from the client side and Output is the response that I send to client. And Room is the fluent model.</p><p>I have extension at the end to get the output from the fluent model. I send baseurl so that I can send full link of the image url that is going to the client side.</p><p>Now lets add a feature to upload images. I send images in the images key from post man. But we need to send images in array hence in postman we can use images[] key to send multiple files as array, check out the picture in the top for detail.</p><p>Now lets write the create function in RoomController</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06d710354ff357935f522d2013e8784b/href">https://medium.com/media/06d710354ff357935f522d2013e8784b/href</a></iframe><p>First I know the the images will be inside the key images, hence I create a strucut Entity just to decode the images.</p><p>Once the images are decoded, Now we need to save it in the server and get the link and add it to the fluent room model. since in fluent Room model, images are just array of strings.</p><p>I use upload path as the combination of public directory, which is the Public folder in the root path, and Date to make the name of the image unique.</p><p>then for each images I wirte file to the public directory, get the file names, add it in Room model and save the Room model and finally return the Output. When returning Output, I append each image filename with the base url so that it will give links like</p><p><a href="http://127.0.0.1:80801633325604.182486_Screenshot2021-07-27at9.07.51AM.png">http://127.0.0.1:80801633325604.182486_Screenshot2021-07-27at9.07.51AM.png</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e845653a419db66fff8d5bb0841cdf9/href">https://medium.com/media/3e845653a419db66fff8d5bb0841cdf9/href</a></iframe><p>To get the baseurl I use this extension</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42f374073d3d461e5c28164cde2f9088/href">https://medium.com/media/42f374073d3d461e5c28164cde2f9088/href</a></iframe><p><strong>One more thing:</strong></p><p>My configure function looks like this. here we use file middleware. And since I will be allowing multiple files, I am increasing the default maxBodySize for the request to 10 mb. By default I think it is 2 mb, and If we upload above that It wont work.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/746b2f1ef9d4134e62f74bc670b87f8e/href">https://medium.com/media/746b2f1ef9d4134e62f74bc670b87f8e/href</a></iframe><p>My folder structure is like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*X1EWDlWr9mIjtBjQ-1ua6w.png" /></figure><p>With this I was able to upload multiple files to the vapor server.</p><p>here is github link to <a href="https://github.com/Iccr/swift-vapor-4-api-basit">repo.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcedc0c2b7d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Postgres connected vapor]]></title>
            <link>https://sisccr.medium.com/postgres-connected-vapor-eeb79794acd5?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/eeb79794acd5</guid>
            <category><![CDATA[vapor]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[server-side-swift]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[error]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Fri, 01 Oct 2021 12:36:13 GMT</pubDate>
            <atom:updated>2021-10-01T12:36:13.056Z</atom:updated>
            <content:encoded><![CDATA[<p>Well this is my first time trying out vapor. I am just starting out for crud operation. I have a post api that sends us to create function of the controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqhuN81XJ2HFK0pn3PZAyA.png" /><figcaption>vapor</figcaption></figure><pre><strong>func create(req: Request)</strong> <strong>throws -&gt; EventLoopFuture&lt;Room&gt; {</strong><br>    let room = try req.content.decode(Room.self)<br>    return room.create(on: req.db).map { room }<br><strong>}</strong></pre><p>but while creating the models I get this error returned</p><pre>server: id of relation violates not-null constraint (ExecConstraints)</pre><p>I had fluent models all setup</p><pre><strong>final class Room: Codable, Model, Content {</strong><br>    static let schema: String = &quot;rooms&quot;<br>    <strong><em>@ID(custom: &quot;id&quot;)</em></strong><br>    var id: Int?<br>    ........</pre><p>and in migration:</p><pre>func prepare(on database: Database) -&gt; EventLoopFuture&lt;Void&gt; {<br>    return database.schema(&quot;rooms&quot;)<br>    <strong>.id()</strong></pre><p>using default key as id, gives us id like <strong>34cfg-rsdflkgj-687dsfasdf,</strong></p><pre>@ID(key: .id)     <br>var id: UUID?</pre><p>I needed custom id as int, hence I used <strong><em>@ID(custom: “id”)</em></strong></p><p>but turns out if we added custom IDtype from fluent, we need to define custome id type in our migration too. otherwise just using <strong>id()</strong> in our migration will make our db id type as <strong>uuid</strong></p><p>changing the migration id type like this, now the types of id of fluent model and the data type in postgres db are same.</p><p><strong>.field(“id”, .int, .identifier(auto: true))</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeb79794acd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drop in Copy to Clipboard function]]></title>
            <link>https://sisccr.medium.com/drop-in-copy-to-clipboard-function-35ba185f6f80?source=rss-1b4232e6708c------2</link>
            <guid isPermaLink="false">https://medium.com/p/35ba185f6f80</guid>
            <category><![CDATA[clipboard]]></category>
            <category><![CDATA[copy]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[paste]]></category>
            <dc:creator><![CDATA[Sis Ccr]]></dc:creator>
            <pubDate>Tue, 28 Sep 2021 05:49:55 GMT</pubDate>
            <atom:updated>2021-09-28T05:51:46.214Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rb0SpVHPvoRo74xyP6tMzg.png" /><figcaption>copy to clibboard</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ea32d7a7ce3ce5af2f306673015f716/href">https://medium.com/media/1ea32d7a7ce3ce5af2f306673015f716/href</a></iframe><pre>self.copyToClipboard(shareableString) {<br>    showSnackBar(message: &quot;Account Details Copied&quot;)<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35ba185f6f80" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>