Home>

About select box using enum

I want to write an enum in a model and create a select box, but I get an error message in the title and cannot implement it.
I want to select a prefecture (prefecture model) and post data (Company model).
Therefore, I would like to give the posted data the value of the prefecture defined by enum.

Undefined method `merge'for
Corresponding source code

prefectures.index.html.erb

<% = form_for (@company, url: admins_companies_path) do | f |%>
      <% #<% = f.hidden_field: prefecture_id ,: value =>@ prefectures.id%>
        
           Added listed companies 
        
        
        <p>Select a prefecture</p>
        <% = f.select: prefecture_name ,: name, Prefecture.prefecture_names.keys%>
        <p>Enter the company name</p>
        <% = f.text_field: company_name%>
        <p>Fill in the description</p>
        <% = f.text_area: description%>
          
          <% = f.attachment_field: image%>
          
        
      <% = f.submit'Create Company'%>
      <% end%>


Prefecture.rb

has_many: companies, dependent:: destroy
   enum prefecture_name: {
     "---": 0,
     hokkaido: 1, aomoriken: 2, iwateken: 3, miyagiken: 4, akitaken: 5, yamagataken: 6, hukushimaken: 7,
     ibarakiken: 8, tochigiken: 9, gunmaken: 10, saitamaken: 11, chibaken: 12, toukyouto: 13, kanagawaken: 14,
     niigataken: 15, toyamaken: 16, ishikawaken: 17, hukuiken: 18, yamanashiken: 19, naganoken: 20,
     gihuken: 21, sizuokaken: 22, aichiken: 23, mieken: 24,
     shigaken: 25, kyoutohu: 26, oosakahu: 27, hyougoken: 28, naraken: 29, wakayamaken: 30,
     tottoriken: 31, simaneken: 32, okayamaken: 33, hiroshimaken: 34, yamaguchiken: 35,
     tokushimaken: 36, kagawaken: 37, ehimeken: 38, kouchiken: 39,
     hukuokaken: 40, sagaken: 41, nagasakiken: 42, kumamotoken: 43, ooitaken: 44, miyazakiken: 45, kagoshimaken: 46,
     okinawaken: 47
   }


CompaniesController

class Admins :: CompaniesController


PrefecturesController

class Admins :: PrefecturesController