title: ActiveModel::UnknownAttributeError unknown attribute 'avatar' - ActiveStorage
body: <p>Currently I'm trying to attach an <code>:avatar</code> field on a Profile. I get the following error:
  <a href="https://i.stack.imgur.com/W3SQt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W3SQt.png" alt="enter image description here"></a></p>
  
  <p>However, following the docs I added the relationshipt of <code>:avatar</code> to Profile.</p>
  
  <pre><code>models/profile.rb
  class Profile &lt; ApplicationRecord
    belongs_to :user
    has_one_attached :avatar
  end
  </code></pre>
  
  <p>I also add <code>:avatar</code> in the strong params. In the Profile controllers.</p>
  
  <pre><code>class ProfilesController &lt; ApplicationController
    def create
      @profile = current_user.create_profile(profile_params)
    end
    ##
    private
  
    def profile_params
       params.require(:profile).permit(:full_name, :city, :bio, :avatar)
    end
  end
  </code></pre>
  
  <p>I wonder if the issue is because of the association between User and Profile. A user has one profile and profile belongs to user.</p>
  
  <pre><code>class User &lt; ApplicationRecord
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :validatable
    has_many :photos
    has_one :profile
  end
  </code></pre>
  
  <p>I request in the <code>profiles/new.html.erb</code> as a file attachement:</p>
  
  <pre><code>&lt;%= form_for @profile do |f| %&gt;
    &lt;div class="form-group"&gt;
      &lt;%= f.label :avatar %&gt;
      &lt;%= f.file_field :avatar, as: :file, class: "form-control" %&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>I see that in the params that the file is in avatar which is why I find so confusing that it doesn't recognize <code>:avatar</code> as an attribute.</p>
  
  <pre><code>Started POST "/profiles" for 127.0.0.1 at 2018-09-22 17:55:26 -0400
  Processing by ProfilesController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==", "profile"=&gt;{"avatar"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0x007ff62db322b8 @tempfile=#&lt;Tempfile:/var/folders/86/g7_xcx392qn815kmkcm55ydc0000gn/T/RackMultipart20180922-10194-awlxd1.png&gt;, @original_filename="profile.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"profile[avatar]\"; filename=\"profile.png\"\r\nContent-Type: image/png\r\n"&gt;
  </code></pre>
  
  <p>I was able to upload attachement for another model so it's not something with the installation. Any ideas why I'm getting this error?</p>