Note that there are some explanatory texts on larger screens.

plurals
  1. POrails - .find returns data from database but missing column
    primarykey
    data
    text
    <p>Ok, i hope the title is descriptive enough but here's my problem. (i'm new to rails so let me know if i need more info as well)</p> <p>I have a form to edit a user on <code>edit.html.erb</code> This gets a <code>@user</code> object passed to it. The code on my controller that gets this is:</p> <pre><code>def edit @user = User.find(params[:id]) end </code></pre> <p>I am using that object to pre-populate the fields on the <code>edit.html.erb</code> page. Here are the columns in my database for users:</p> <pre><code>id username name email admin active created_at updated_at </code></pre> <p>My problem is that for some reason the value of <code>email</code> is being left off of the object, thus the values all get shifted left. For example, by using <code>&lt;%= @user.inspect %&gt;</code> on the <code>edit.html.erb</code> page this is what i get:</p> <pre><code>&lt;User id: 2, username: "exampleuser1", name: "Kaylee Kuhic", nickname: "exampleuser1", email: "Default", selected_color_scheme: "0", is_admin: true, active: nil, date_last_logged_in: "2012-08-30 19:28:31", created_at: "2012-08-30 19:28:31", updated_at: nil&gt; </code></pre> <p>This is just a test application i'm tinkering with so i may have moved a column around. Would that affect it? <strong>What is happening between the controller and the view that could be affecting the object?</strong></p> <p>Also, when i run <code>User.find(params[:id])</code> in the rails console i get all the data returned back correctly:</p> <pre><code>&lt;User id: 2, username: "exampleuser1", name: "Kaylee Kuhic", nickname: "exampleuser1", email: "exampleuser1@example.com", selected_color_scheme: "Default", is_admin: true, active: true, date_last_logged_in: nil, created_at: "2012-08-30 19:28:31", updated_at: "2012-08-30 19:28:31"&gt; </code></pre> <p>Any thoughts? Again, sorry if i have left out any vital info.</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