Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Playing with Devise user modelss (Mongoid/Rails)
Ruby CoffeeScript JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
db
doc
lib
log
public
script
test
vendor
.gitignore
Gemfile
Gemfile.lock
README.md
README.rdoc
Rakefile
config.ru

README.md

 bearded-octo

Rails web-app playing with Devise and Mongoid.

Just a place to play with some of the things Devise can do for User models. In this case using Mongoid as a personal preference, but also to see what it can do.

Models

Currently, Admin and Company. For 'Company' read 'regular User'.

Wanted to set up a User model that allowed for overall SuperAdmin/Access-All-Areas for Admin and restricted areas for other groups of users.

Several ways to go from here, but I have implemented (this round at least) a system where the controllers before filters figure out who gets access.

Quick but messy as I had to define methods on each controller (see below).

Will be looking at other ways of doing this going forward. (Probably from looking at the Devise example apps: https://github.com/plataformatec/devise/wiki/Example-Applications)

Would welcome suggestions and pull requests.

Example method on app/controllers/company_controller.rb

Uses the Devise method [user_model]_signed_in? and declare the before_filter

    def is_company_unless_admin
      unless admin_signed_in? or company_user_signed_in?
        redirect_to new_company_user_session_path, alert: "You must be logged in to access this Corporate Hospitality area"
      end
    end
Something went wrong with that request. Please try again.