<?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: wusher</title>
    <description>The latest articles on DEV Community by wusher (@wusher).</description>
    <link>https://dev.to/wusher</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%2F690807%2F70e7c1bb-7043-442c-be25-9ba98c3e6d4e.jpeg</url>
      <title>DEV Community: wusher</title>
      <link>https://dev.to/wusher</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wusher"/>
    <language>en</language>
    <item>
      <title>Feature Flags On Rails Routes</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Sun, 04 Sep 2022 08:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/feature-flags-on-rails-routes-48dj</link>
      <guid>https://dev.to/wusher/feature-flags-on-rails-routes-48dj</guid>
      <description>&lt;p&gt;Found a &lt;a href="https://twitter.com/julian_rubisch/status/1565244598204645376"&gt;tweet&lt;/a&gt; explaining how to wrap a rails route with a feature flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resources :media,
      constraints: -&amp;gt;(req) do
                     current_user = req.env["warden"].user(:user)
                     Flipper.enabled?(:media_uploads, current_user)
                   end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source: &lt;a href="https://twitter.com/carbon%5C_noreply/status/1565244390666252288"&gt;https://twitter.com/carbon\_noreply/status/1565244390666252288&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>flipper</category>
    </item>
    <item>
      <title>Active Storage Variants Failing Locally</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Fri, 02 Sep 2022 09:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/active-storage-variants-failing-locally-1glm</link>
      <guid>https://dev.to/wusher/active-storage-variants-failing-locally-1glm</guid>
      <description>&lt;h4&gt;
  
  
  Setup
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;ruby 3.0.4p208&lt;/li&gt;
&lt;li&gt;puma 5.6.1&lt;/li&gt;
&lt;li&gt;Rails 7.0.2&lt;/li&gt;
&lt;li&gt;macos 12.4 m1 
#### Issue&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I kept getting broken images when generating variants locally. I found the error below in my rails logs.&lt;/p&gt;

&lt;h4&gt;
  
  
  Error
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called
[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Fix
&lt;/h4&gt;

&lt;p&gt;I had to add this to my &lt;code&gt;zshrc&lt;/code&gt; before I initialize &lt;code&gt;rbenv&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>rails</category>
      <category>puma</category>
    </item>
    <item>
      <title>File Uploads Without Form Helpers</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Fri, 02 Sep 2022 08:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/file-uploads-without-form-helpers-2a6m</link>
      <guid>https://dev.to/wusher/file-uploads-without-form-helpers-2a6m</guid>
      <description>&lt;p&gt;When uploading files without using the form helper &lt;code&gt;form.file_field&lt;/code&gt;, you have to add the option &lt;code&gt;multipart: true&lt;/code&gt; to the form tag.&lt;/p&gt;

&lt;p&gt;Discovered in &lt;a href="https://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-file_field_tag"&gt;API Docs&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt; %= form_with(model: @company), multipart: true) do |form| %&amp;gt;

    -- When using: --
    &amp;lt;input type="file" name="company[logo]" /&amp;gt;
    -- OR --
    &amp;lt; %= file_field_tag "company[logo]" %&amp;gt;

    &amp;lt; %= form.submit %&amp;gt;
  &amp;lt; % end %&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>rails</category>
    </item>
    <item>
      <title>Unregister Service Workers</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Thu, 01 Sep 2022 08:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/unregister-service-workers-3nhj</link>
      <guid>https://dev.to/wusher/unregister-service-workers-3nhj</guid>
      <description>&lt;p&gt;A little bit of code to unregister all service workers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (navigator.serviceWorker) {
  navigator.serviceWorker.getRegistrations().then(function (registrations) {
    for (let registration of registrations) {
      registration.unregister();
    }
  });
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>pwa</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Inline Bundler Without Gemfile</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Thu, 01 Sep 2022 08:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/inline-bundler-without-gemfile-21n3</link>
      <guid>https://dev.to/wusher/inline-bundler-without-gemfile-21n3</guid>
      <description>&lt;p&gt;For quick throwaway ruby scripts, you can add your gemfile inline. When you run the file, ruby will install your dependencies and then execute the script.&lt;/p&gt;

&lt;h4&gt;
  
  
  Inline bundler
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# BEGIN inline bundler 
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'httparty'
  gem 'pry'
end
# END inline bundler 

resp = HTTParty.get "https://rubygems.org"
binding.pry 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Running
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; ruby tmp.rb 

From: /Users/user/code/tmp.rb:11 :

     6: gem 'httparty'
     7: gem 'pry'
     8: end
     9: 
    10: resp = HTTParty.get "https://rubygems.org"
 =&amp;gt; 11: binding.pry 

[1] pry(main)&amp;gt; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ruby</category>
    </item>
    <item>
      <title>Uninstall All Bundled Gems</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Thu, 01 Sep 2022 08:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/uninstall-all-bundled-gems-5bl6</link>
      <guid>https://dev.to/wusher/uninstall-all-bundled-gems-5bl6</guid>
      <description>&lt;p&gt;I came across a quick way to delete all the gems installed through bundler. &lt;a href="https://stackoverflow.com/a/21385516/1632"&gt;source&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle list | ruby -e 'ARGF.readlines[1..-1].each {|l| g = l.split(" "); puts "Removing #{g[1]}"; `gem uninstall --force #{g[1]} -v #{g[2].gsub(/\(|\)/, "")}`; }'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Line by line version
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle list 
ruby -e '
  ARGF.readlines[1..-1].each {|l| g = l.split(" ")
  puts "Removing #{g[1]}"
  `gem uninstall --force #{g[1]} -v #{g[2].gsub(/\(|\)/, "")}`
}'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ruby</category>
      <category>bundler</category>
    </item>
    <item>
      <title>Signout Users</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Thu, 01 Sep 2022 08:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/signout-users-448a</link>
      <guid>https://dev.to/wusher/signout-users-448a</guid>
      <description>&lt;p&gt;Code to logout deactivated users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if current_user&amp;amp;.deactivated_at
  email = current_user.email
  sign_out current_user
  redirect_to root_path, alert: "Your account has been deactivated. Account: #{email} "
end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>rails</category>
      <category>devise</category>
    </item>
    <item>
      <title>Makefile Help</title>
      <dc:creator>wusher</dc:creator>
      <pubDate>Wed, 31 Aug 2022 08:01:01 +0000</pubDate>
      <link>https://dev.to/wusher/makefile-help-245b</link>
      <guid>https://dev.to/wusher/makefile-help-245b</guid>
      <description>&lt;p&gt;Not sure where I picked this up, but I always add a help command to my make files:&lt;/p&gt;

&lt;h4&gt;
  
  
  Skeleton File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.PHONY: clean help lint setup start test

help: ## shows the help
    @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

clean: ## clean the project
  echo TODO 

lint: ## lint codebase
  echo TODO 

setup: ## install all deps and configure project
  echo TODO 

start: ## compile and run the server 
  echo TODO 

test: ## run the tests 
  echo TODO 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; make 
clean clean the project
help shows the help
lint lint codebase
setup install all deps and configure project
start compile and run the server 
test run the tests 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>makefile</category>
    </item>
  </channel>
</rss>
