I was trying to debug why <%= @user.address1 %> wasn't showing up in the view. The associated column was setup as a string, as in:
t.string "address1"
t.string "address2"
t.string "city"
t.string "state"
t.string "zip"
t.string "phone"
When I debugged the model using debug(@user), I got:
address1: 123 Main St.
city: Santa Barbara
address2: ""
zip: "93101"
state: CA
Associated view for inputting info into the db:
<tr>
<td width="300">Address: </td>
<td><%= u.text_field :address1 %><br></td>
</tr>
<tr>
<td width="300">Address2: </td>
<td><%= u.text_field :address2 %><br></td>
</tr>
<tr>
<td>City:</td>
<td><%= u.text_field :city %></td>
</tr>
<tr>
<td>State:</td>
<td><%= u.text_field :state %></td>
</tr>
<tr>
<td>Zip Code:</td>
<td><%= u.text_field :zip %></td>
</tr>
<tr>
<td>Phone:</td>
<td><%= u.text_field :phone %></td>
</tr>
I fixed the problem by using <%= @user.address1.to_s %> but from the debug output along with the schema I thought the column was already a string. I did notice that while the zip code contained quotations around it designating a string, the address1 did not.
So why couldn't I initially use <% [email protected] %> without converting it to string? What kind of variable is the 123 main st. without quotations?