Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting an atttribute in rails console - transaction rolled back
    primarykey
    data
    text
    <p>I've used this forum gem before and also been able to set the forem_admin to "true" using the console. However, this time it's rolling back the transaction when I try to save. </p> <p>You can see below that I set the forem_admin to "true," saved it, it rolled back the transaction (which means it didn't save), I did "u" and it showed forem_admin = true but when I restarted the console it showed forem_admin = false. </p> <p>If anyone's familiar with this gem, I think this forem_state attribute is new, so I'm wondering if anything's changed. </p> <p>I'm not an SQL pro but one thing that looks funny to me is the line</p> <pre><code>"users"."id" != 5 </code></pre> <p>I would have expected it to have been <code>"users"."id" = 5</code> i.e. with no "!", because the id of the user "signuplinks" is 5. </p> <p>this is a rails 3.2 app</p> <p><strong>update</strong> when I do <code>u.errors</code> after u.save, I'm getting this error message</p> <pre><code>@messages={:password=&gt;["can't be blank"]} </code></pre> <p><strong>Console</strong> </p> <pre><code> ruby-1.9.3-rc1 :001 &gt; u = User.last User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 =&gt; #&lt;User id: 5, email: "myemail@gmail.com", encrypted_password: "$2a$10$axjwcO.kU4/mqC9Llyj.b.r/2jJULnWKmG7Pi3Zu1AE3...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2012-03-05 03:37:59", last_sign_in_at: "2012-03-05 03:37:59", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2012-03-05 03:37:58", confirmation_sent_at: "2012-03-05 03:34:33", unconfirmed_email: nil, created_at: "2012-03-05 03:34:33", updated_at: "2012-03-05 03:37:59", name: "signuplinks", country: "Canada", image: "3.png", forem_admin: false, forem_state: "pending_review"&gt; ruby-1.9.3-rc1 :002 &gt; u.forem_admin = true =&gt; true ruby-1.9.3-rc1 :003 &gt; u.save (0.1ms) begin transaction User Exists (0.2ms) SELECT 1 FROM "users" WHERE (LOWER("users"."name") = LOWER('signuplinks') AND "users"."id" != 5) LIMIT 1 User Exists (0.1ms) SELECT 1 FROM "users" WHERE (LOWER("users"."email") = LOWER('signuplinks@gmail.com') AND "users"."id" != 5) LIMIT 1 (0.1ms) rollback transaction =&gt; false ruby-1.9.3-rc1 :004 &gt; u =&gt; #&lt;User id: 5, email: "myemail@gmail.com", encrypted_password: "$2a$10$axjwcO.kU4/mqC9Llyj.b.r/2jJULnWKmG7Pi3Zu1AE3...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2012-03-05 03:37:59", last_sign_in_at: "2012-03-05 03:37:59", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2012-03-05 03:37:58", confirmation_sent_at: "2012-03-05 03:34:33", unconfirmed_email: nil, created_at: "2012-03-05 03:34:33", updated_at: "2012-03-05 03:37:59", name: "signuplinks", country: "Canada", image: "3.png", forem_admin: true, forem_state: "pending_review"&gt; ruby-1.9.3-rc1 :005 &gt; exit Michael-Pro:ic michl$ rails c Loading development environment (Rails 3.2.1) ruby-1.9.3-rc1 :001 &gt; u = User.last User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 =&gt; #&lt;User id: 5, email: "myemail@gmail.com", encrypted_password: "$2a$10$axjwcO.kU4/mqC9Llyj.b.r/2jJULnWKmG7Pi3Zu1AE3...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2012-03-05 03:37:59", last_sign_in_at: "2012-03-05 03:37:59", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2012-03-05 03:37:58", confirmation_sent_at: "2012-03-05 03:34:33", unconfirmed_email: nil, created_at: "2012-03-05 03:34:33", updated_at: "2012-03-05 03:37:59", name: "signuplinks", country: "Canada", image: "3.png", forem_admin: false, forem_state: "pending_review"&gt; </code></pre>
    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