title: How to avoid create some attribute in controller's create method?
body: <p>I have a model like this:</p>
  
  <pre><code>class Url &lt; ApplicationRecord
    validates ...
    before_create :generate_number
  
    def generate_number
      self.number = a random value
    end
  end
  </code></pre>
  
  <p>and a <code>create()</code> method in controller:</p>
  
  <pre><code>def create
    @url = Url.new(url_params)
  
    respond_to do |format|
      if @url.save
        format.html { redirect_to @url, notice: 'Url was successfully created.' }
        format.json { render :show, status: :created, location: @url }
      else
        format.html { render :new }
        format.json { render json: @url.errors, status: :unprocessable_entity }
      end
    end
  end
  </code></pre>
  
  <p>My DB only have two fields: <code>given_url</code> and <code>number</code>. Now, when I go to the <code>new</code> page, there's 2 input form for <code>given_url</code> and <code>number</code>. But I want <code>number</code> take the value from <code>generate_number</code>, not from the form. How can I do that?</p>
  
  <p>Or more specific, is there a way to make the <code>generate_number</code> method to overrides user's input after the app already receive value from user's input?</p>