title: Rails: "private method `require' called for #<Hash..." when creating a record manually (not through the form)
body: <p>I have a text file with data which I need to store in the database.</p>
  
  <p>In a Rails controller action, I have something like this:</p>
  
  <pre><code>class ImportDataController &lt; ApplicationController
    protect_from_forgery except: :abc_client
  
    def abc_client
      ...simplified code:...
      ...loading data from a file...
      car = {}
      car[:attr1] = something
      car[:attr2] = something
      car[:attr3] = something
      ...and so on...
  
      ...now I try to save the record to the DB...
      @car = Cars::Crud::CreateService.new(car).create
    end
  end
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre><code>private method `require' called for #&lt;Hash:0x007fb2e2ef6040&gt;
  </code></pre>
  
  <p>and the error points on this block of the code:</p>
  
  <pre><code>def car_params(params)
    params.require(:car).permit(:attr1, :attr2, ...)
  </code></pre>
  
  <p>I tried to also create a record "normally" via a Rails form and copied the hash from the console and tried to save it, like:</p>
  
  <pre><code>params = {"utf8"=&gt;"✓", "authenticity_token"=&gt;"kXMd23s4msX2OzhUAX2CWqyphnpCPNorQOvoitatj8uBsQBgGYbTgfoR1wTTWlufo++esyb5m9ogBfSHbCrAPA==", "car"=&gt;{"attr1"=&gt;"6", ...
  
  @car = Cars::Crud::CreateService.new(params).create
  </code></pre>
  
  <p>But it resulted in the same error message.</p>
  
  <p>How do I figure it out?</p>
  
  <p>Thank you</p>