Ruby on Rails 5.2.3 Radio Buttons problem when saving

Hi All,

I’m having a problem when it comes to saving to a form, only when it comes to the Radio Buttons.

Here’s the code I’m using for the radio buttons

<div class="field">
<%= form.label :type %><br />
<%= form.radio_button :type, 'Playlist' %> Playlist
<%= form.radio_button :type, 'BlogPost' %> BlogPost
<%= form.radio_button :type, 'Competition' %> Competition

All the other fields in the form save correctly when the Radio Button is ignored.

Heres the error …

uninitialized constant BlogPost

Request parameters	
{"utf8"=>"✓", "authenticity_token"=>"BTOJZv+eDZnbESYxzEm0y7ZN/D/n+10oiytrPFp5KRsX1c4537/gCE4cJLN71xtkrpCii7GVsGnut7Ixq0Zytg==", "article"=>{"type"=>"BlogPost", "title"=>"", "intro"=>"", "content"=>"", "publish_date(1i)"=>"2019", "publish_date(2i)"=>"10", "publish_date(3i)"=>"13", "publish_date(4i)"=>"20", "publish_date(5i)"=>"37", "published"=>"0"}, "commit"=>"Create Article", "controller"=>"articles", "action"=>"create"}

The Type field, is a String, BlogPost was selected for this example, the unititialized constant changes wo whichever option is selected

If anyone has any suggestions, or if more info is needed, please ask away

The problem is probably because ActiveRecord recognizes ‘type’ as a reserved word that it uses for inheritance. So he’s looking for a model called BlogPost and inherits from Article.