Skip to content

Migration from 1.0 to master with non-admin user logged in causes Error undefined method `waiting_approval?' for nil:NilClass #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
donthorp opened this issue Feb 23, 2013 · 4 comments · Fixed by #116
Assignees
Labels
Milestone

Comments

@donthorp
Copy link
Member

Reset to v1.0

git checkout v1.0
bundle install to update the gems
bundle exec rake db:drop db:create db:migrate kandan:bootstrap
bundle exec thin start

Create a non-admin user and login

Make a backup copy of the DB

cd db
cp development.sqlite3 development.sqlite3.backup
cd ..

Switch back to master

git checkout master
bundle install
bundle exec rake db:migrate kandan:bootstrap
bundle exec thin start

Return to broswer and access site. Error undefined method `waiting_approval?' for nil:NilClass will occur.

force_approved_accountapp/controllers/application_controller.rb

      4   before_filter :force_approved_account
      5   before_filter :redirect_suspended_account
      6 
      7   def force_approved_account
      8           # We will redirect to the approval page if a user is signed in, is not an admin and is marked as waiting for approval
      9           redirect = user_signed_in? && !current_user.is_admin? && current_user.status.waiting_approval?
     10 
     11           redirect_to approval_path if redirect
     12   end
     13 
     14   def redirect_suspended_account
@ghost ghost assigned gabceb Feb 23, 2013
@gabceb
Copy link
Member

gabceb commented Feb 23, 2013

Need to add a migration to give the column status on the table users a default value. Prob active should be the value

@jrgifford
Copy link
Member

Could it somehow be a toggle in config/permissions.yml or something, where you can set public or private, and if it's public, then have it be active, or if its private, then pending?

@gabceb
Copy link
Member

gabceb commented Feb 24, 2013

This only happens if you are updating from 1.0 to 1.1 and had users in your database. I think it is safe to assume that if you had users in the system you still want those users as active.

Another option would be to find a way to get rake db:migrate to read from the config file where there is a variable for the site to be public or private and set the status accordingly but I think this is kind of overkill.

@jrgifford
Copy link
Member

Ah, ok. I misunderstood the exact conditions this appeared under.

agreed, overkill.

@gabceb gabceb closed this as completed in 7896ffe Feb 26, 2013
ar7em pushed a commit to ar7em/kandan that referenced this issue Jun 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants