I'm learning RoR and my development db is the default, sqlite and I'm deploying my app to Heroku which uses posgresql. I understand that to avoid such issues, I should develop with postgresql as well, and in future I intend to do this. However, I've got an issue that appears in production but not dev.
Issue: I've got a User and an Account model. A User can have many Accounts.
I made a migration so that when an Account is created, its active field is set to true by default.
class UpdateDefaultAccountActiveValue < ActiveRecord::Migration
def change
change_column_default(:accounts, :active, true)
end
end
This appears to work in dev.
In /views/accounts/index.html.erb, the following code outputs true or false depending on whether an account is active or not.
<% @accounts.each do |account| %>
<tr>
<% if !(account.credit) %>
<td><%= link_to account.name, history_url(id: account.id) %></td>
<% else %>
<td><%= link_to account.name + ' (Credit)', history_url(id: account.id) %></td>
<% end %>
<td><%= account.active %></td>
<td><%= link_to 'Edit', edit_account_path(account) %></td>
</tr>
<% end %>
However, in production, the /views/accounts/index.html.erb doesn't output true or false depending on whether an account is active or not.
Why is this and how can I resolve this?
papertrail log:
2016-05-25T21:34:06.348465+00:00 app[web.1]: Started GET "/accounts" for 176.248.123.34 at 2016-05-25 21:34:06 +0000
2016-05-25T21:34:06.355649+00:00 app[web.1]: Processing by AccountsController#index as HTML
2016-05-25T21:34:06.447420+00:00 app[web.1]: Completed 200 OK in 94ms (Views: 64.5ms | ActiveRecord: 18.2ms)
2016-05-25T21:34:06.452111+00:00 heroku[router]: at=info method=GET path="/accounts" host=???.herokuapp.com request_id=f33ab960-5c1b-4883-a28c-8c2b40388bad fwd="176.248.123.34" dyno=web.1 connect=0ms service=107ms status=200 bytes=4073
$heroku run rails consolein terminal, find an account instance and check out the attr. If nil find all the instances of the class and set it true. Then add anull: falseconstraint to the db column with migration. Extra: change the order of the 2 options and use<% if account.credit %>. And you should change the development db to pg as soon as possible.$heroku logs --tail2. from papertrail: you just click on papertrail from heroku dashboard200status code. Have you checked the attr values of the boolean field?