Closed stereodenis closed 10 years ago
Are you using Rails 4.1.0.rc2? Does the migration work if you use SQLite?
Closing issue due to lack of response.
I tried this too and it didn't work. So i thought it would be better to create roles like this.
# have zero as the default role. Since enum auto does it for me
t.integer :role, default: 0, null: false
#then my user model looks like this
enum role: [:user, :banned, :admin]
Not sure if it's bad but it seems to work.
The vagueness...location?
Do you have an issue to report?
@jackson-sandland not sure i understand your comment.
@DanielKehoe I'm having this exact same issue...I'm using Devise and Rails 4 - the sign up works beautifully locally, but not on heroku. These are the logs =>
2014-07-08T22:45:47.074079+00:00 app[web.1]: Processing by Devise::RegistrationsController#new as HTML
2014-07-08T22:45:47.087034+00:00 app[web.1]: F, [2014-07-08T22:45:47.086932 #5] FATAL -- :
2014-07-08T22:45:47.087038+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "admin" does not exist
2014-07-08T22:45:47.087039+00:00 app[web.1]: LINE 5: WHERE a.attrelid = '"admin"'::regclass
2014-07-08T22:45:47.087043+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2014-07-08T22:45:47.087041+00:00 app[web.1]: ^
2014-07-08T22:45:47.087045+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2014-07-08T22:45:47.087046+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2014-07-08T22:45:47.087065+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:430:in log' 2014-07-08T22:45:47.087048+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum 2014-07-08T22:45:47.087056+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:774:in
async_exec'
2014-07-08T22:45:47.087049+00:00 app[web.1]: WHERE a.attrelid = '"admin"'::regclass
2014-07-08T22:45:47.087063+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.3/lib/active_support/notifications/instrumenter.rb:20:in instrument' 2014-07-08T22:45:47.087082+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/schema_cache.rb:56:in
yield'
2014-07-08T22:45:47.087051+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2014-07-08T22:45:47.087058+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/ac
@DanielKehoe I have reset the database on Heroku. I have checked the schema. Admin is a table that exists, and the routes are defined in routes.rb.
I've just deployed the app to Heroku and did not encounter any problem. Try:
$ heroku pg:reset DATABASE
$ heroku run rake db:migrate
$ heroku run rake db:seed
$ heroku restart
Maybe you forgot to run $ heroku run rake db:migrate
?
Also check your Gemfile to make sure you've specified:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.4'
Also you say that "Admin is a table that exists." But the application has no table named 'admin'. The table is 'users'.
@DanielKehoe Thank you! I ran the migration and then checked the results...I must have deleted a migration so when I rake:db migrated the app on heroku the Admin table was not being created. I made a new migration, and I have solved that issue! However, now I am getting a 500 error in the Heroku logs because I added a :username attribute to the Devise form, but it is producing the following:
2014-07-08T23:55:19.663959+00:00 app[web.1]: Rendered devise/registrations/new.html.erb within layouts/application (2.0ms)
2014-07-08T23:55:19.667137+00:00 app[web.1]: ActionView::Template::Error (undefined method `username' for #
2014-07-08T23:55:19.667144+00:00 app[web.1]: 7: <%= f.text_field :username, autofocus: true %>
I can help you when you encounter errors with the example application. I can't help with errors introduced by your custom code.
My Rails and Devise Tutorial has a chapter on adding additional attributes to the Devise views. It might be helpful. You can also ask on Stack Overflow.
Thank you Daniel. It's working!
On Tue, Jul 8, 2014 at 5:03 PM, Daniel Kehoe notifications@github.com wrote:
I can help you when you encounter errors with the example application. I can't help with errors introduced by your custom code.
My Rails and Devise Tutorial http://railsapps.github.io/rails-devise/ has a chapter on adding additional attributes to the Devise views. It might be helpful. You can also ask on Stack Overflow.
— Reply to this email directly or view it on GitHub https://github.com/RailsApps/rails-devise-pundit/issues/5#issuecomment-48414900 .