<?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: Raghu Betina</title>
    <description>The latest articles on DEV Community by Raghu Betina (@raghubetina).</description>
    <link>https://dev.to/raghubetina</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%2F450254%2Fc3e560fe-6c9a-48bb-8a3b-8469791095d7.jpeg</url>
      <title>DEV Community: Raghu Betina</title>
      <link>https://dev.to/raghubetina</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raghubetina"/>
    <language>en</language>
    <item>
      <title>TIL: ERB verbatim tag</title>
      <dc:creator>Raghu Betina</dc:creator>
      <pubDate>Sat, 17 May 2025 15:37:23 +0000</pubDate>
      <link>https://dev.to/raghubetina/til-erb-verbatim-tag-5cnf</link>
      <guid>https://dev.to/raghubetina/til-erb-verbatim-tag-5cnf</guid>
      <description>&lt;p&gt;TIL about the new-ish "verbatim" ERB tag: &lt;code&gt;&amp;lt;%==&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://guides.rubyonrails.org/active_support_core_extensions.html#safe-strings" rel="noopener noreferrer"&gt;https://guides.rubyonrails.org/active_support_core_extensions.html#safe-strings&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="n"&gt;something&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is equivalent to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;something&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ruby</category>
      <category>rails</category>
      <category>tutorial</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>TIL: Hash value omission in Ruby 3</title>
      <dc:creator>Raghu Betina</dc:creator>
      <pubDate>Mon, 13 Mar 2023 21:08:04 +0000</pubDate>
      <link>https://dev.to/raghubetina/til-hash-value-omission-in-ruby-3-5bgp</link>
      <guid>https://dev.to/raghubetina/til-hash-value-omission-in-ruby-3-5bgp</guid>
      <description>&lt;p&gt;Today I learned that &lt;a href="https://bugs.ruby-lang.org/issues/14579"&gt;as of Ruby 3&lt;/a&gt;, we can omit values from hashes if the key name matches the expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# In Rubies &amp;lt; v3:&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"alice"&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"bob"&lt;/span&gt;

&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;a: &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;b: &lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# In Rubies &amp;gt;= v3:&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"alice"&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"bob"&lt;/span&gt;

&lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Rails partials can have their own layouts</title>
      <dc:creator>Raghu Betina</dc:creator>
      <pubDate>Tue, 10 Jan 2023 17:07:32 +0000</pubDate>
      <link>https://dev.to/raghubetina/rails-partials-can-have-their-own-layouts-46k7</link>
      <guid>https://dev.to/raghubetina/rails-partials-can-have-their-own-layouts-46k7</guid>
      <description>&lt;p&gt;TIL that Rails partials can have their own layouts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://edgeapi.rubyonrails.org/classes/ActionView/PartialRenderer.html#class-ActionView::PartialRenderer-label-Rendering+partials+with+layouts"&gt;https://edgeapi.rubyonrails.org/classes/ActionView/PartialRenderer.html#class-ActionView::PartialRenderer-label-Rendering+partials+with+layouts&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a multi-step form in Rails with Wicked</title>
      <dc:creator>Raghu Betina</dc:creator>
      <pubDate>Mon, 10 Aug 2020 17:10:31 +0000</pubDate>
      <link>https://dev.to/raghubetina/building-a-multi-step-form-in-rails-with-wicked-l0g</link>
      <guid>https://dev.to/raghubetina/building-a-multi-step-form-in-rails-with-wicked-l0g</guid>
      <description>&lt;p&gt;I wanted to make a wizard to help students visualize the relationships between their database tables, so I had a chance to play with &lt;a href="https://github.com/zombocom/wicked#step-by-step-wizard-controllers"&gt;the Wicked gem&lt;/a&gt;. Here is the work-in-progress:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://association-accessors.firstdraft.com/"&gt;https://association-accessors.firstdraft.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Wicked gem has a good README but the example within centers around a signup form. Since my wizard is not for a user model (and thus doesn’t have &lt;code&gt;current_user&lt;/code&gt;), and since I have validations that I wanted to enforce at some steps but not others, I found this blog post very helpful:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.joshmcarthur.com/2014/12/23/rails-multistep-forms.html"&gt;https://www.joshmcarthur.com/2014/12/23/rails-multistep-forms.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That post got me 99% of the way, but a few additional notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;My wizard has conditional logic; it's not a linear path. So my update action has some &lt;code&gt;jump_to&lt;/code&gt;s:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'nature'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="vi"&gt;@association&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indirect?&lt;/span&gt;
  &lt;span class="n"&gt;jump_to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:join_table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;render_wizard&lt;/span&gt;
&lt;span class="k"&gt;elsif&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'foreign_key'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="vi"&gt;@association&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;valid?&lt;/span&gt;
  &lt;span class="n"&gt;jump_to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;render_wizard&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
  &lt;span class="n"&gt;render_wizard&lt;/span&gt; &lt;span class="vi"&gt;@association&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;It will be interesting to think about how to generalize this for more complicated wizards. Do we capture the logic in a full-on state machine, and use that to decide where to &lt;code&gt;jump_to&lt;/code&gt;?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I re-rendered previous form fields and disabled them to remind the user what they'd already entered, so breaking each form-group into its own partial was very helpful.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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