Note that there are some explanatory texts on larger screens.

plurals
  1. POHandling PostgreSQL Creating Tables, Associations, and Rails
    primarykey
    data
    text
    <p>Long story short I decided to wipe out my database on my localhost and experiment with posgreSQL and pgAdmin with my Rails app. I first deleted any servers I had via pgAdmin. I then ran <code>db:create:all</code>, <code>db:migrate</code>, and finally <code>db:test:prepare</code>. Now whenever I run my previous spec tests before I did all this database experimentation the majority of my tests fails giving me this error..</p> <pre><code> Failure/Error: @user = FactoryGirl.create(:user) NoMethodError: undefined method `password_reset_sent_at' for #&lt;User:0xb48a55c&gt; </code></pre> <p>or </p> <pre><code> Failure/Error: @user.save NoMethodError: undefined method `password_reset_sent_at' for #&lt;User:0xaa9c040&gt; </code></pre> <p>I thought I may have not allowed <code>password_reset_sent_at</code> as a non-accessible attribute but it is accessible and my user model has the <code>has_one :user_reset_password, :dependent =&gt; :destroy</code>.</p> <p>My database.yml looks like...</p> <pre><code>development: adapter: postgresql encoding: unicode database: template_development host: localhost pool: 5 username: jason password: password test: adapter: postgresql encoding: unicode database: template_test host: localhost pool: 5 username: jason password: password </code></pre> <p>When I run the application and I create a new user I get this error.</p> <pre><code>undefined method `password_reset_sent_at' for #&lt;User:0xa6fb184&gt; app/models/user.rb:78:in `empty_password_reset_token' app/controllers/users_controller.rb:25:in `create' </code></pre> <p>The <code>empty_password_reset_token</code> method is</p> <pre><code>def empty_password_reset_token if self.password_digest_changed? if self.password_reset_sent_at &amp;&amp; self.password_reset_sent_at &lt; 2.hours.ago false else self.password_reset_token = "" self.password_reset_sent_at = "" end end end </code></pre> <p>My schema file</p> <pre><code>ActiveRecord::Schema.define(:version =&gt; 20130124193639) do create_table "user_login_failures", :force =&gt; true do |t| t.integer "user_id" t.integer "login_failure_attempts" t.datetime "created_at", :null =&gt; false t.datetime "updated_at", :null =&gt; false end create_table "user_reset_passwords", :force =&gt; true do |t| t.integer "user_id" t.string "password_reset_token" t.datetime "password_reset_sent_at" t.datetime "created_at", :null =&gt; false t.datetime "updated_at", :null =&gt; false end create_table "users", :force =&gt; true do |t| t.string "name" t.string "email" t.datetime "created_at", :null =&gt; false t.datetime "updated_at", :null =&gt; false t.string "password_digest" end add_index "users", ["email"], :name =&gt; "index_users_on_email", :unique =&gt; true end </code></pre> <p>I really have no idea why this is not working. The tables all have the appropriate columns and nothing is missing. Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload