title: How to avoid the validation, callbacks and 'attr_accessible' effects during the seeding process using Ruby on Rails 3?
body: <p>I am using Ruby on Rails 3 and I am trying to seed data in my application database.</p>
  
  <p>In 'RAILS_ROOT/models/user.rb' I have:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    attr_accessible #none
  
    validates :name,
      :presence =&gt; true
    validates :surname,
      :presence =&gt; true
    validates :email,
      :presence =&gt; true
  end
  </code></pre>
  
  <p>In 'RAILS_ROOT/db/seeds.rb' I have:</p>
  
  <pre><code># Test 1
  User.find_or_create_by_email (
    :name       =&gt; "Test1 name",
    :surname    =&gt; "Test1 surname",
    :email      =&gt; "test1@test1.test1"
  )
  
  # Test2
  User.find_or_create_by_email (
    :name       =&gt; "",
    :surname    =&gt; "",
    :email      =&gt; "test2@test2.test2"
  )
  </code></pre>
  
  <p>So, running in the Terminal</p>
  
  <pre><code>rake db:seed
  </code></pre>
  
  <p>of course the database will NOT populate with datas because 'attr_accessible' to nil (Case Test1) and validation not passed (Case Test2).</p>
  
  <p><em>I would like to skip the validation and "attr-accessible effects" during the seeding process.</em> <strong>Is it possible? If so, how to do that?</strong></p>
  
  <p>P.S.: I don't want to use in 'RAILS_ROOT/db/migrate/201....rb' code like this: </p>
  
  <pre><code>execute "INSERT INTO users ( name, surname, email ) VALUES ( "Test1 name", "Test1 surname", "test1@test1.test1")"
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I need also to <em>skip all callbacks</em>. <strong>Is it possible? If so, how?</strong></p>