Giter VIP home page Giter VIP logo

backstage's Introduction

README

This application is nothing more than a test of rolify, cancan and devise. The intent is to play around with the basic setup and test it’s functionality so that we know how much we can stretch the design for various implementations.

The basic install is from Eppo’s rolify tutorial: github.com/EppO/rolify/wiki/Tutorial

# rails generate devise:install

create  config/initializers/devise.rb
create  config/locales/devise.en.yml

# Ensure you have defined default url options in your environments files. Here

is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }

In production, :host should be set to the actual host of your application.

# Ensure you have defined root_url to something in your config/routes.rb.

For example:

  root :to => "home#index"

# flash messages in app/views/layouts/application.html.erb.

For example:

  <p class="notice"><%= notice %></p>
  <p class="alert"><%= alert %></p>

# rails generate devise User

invoke  active_record
create    db/migrate/20140128165238_devise_create_users.rb
create    app/models/user.rb
invoke    test_unit
create      test/models/user_test.rb
create      test/fixtures/users.yml
insert    app/models/user.rb
 route  devise_for :users

# rails generate cancan:ability

create  app/models/ability.rb

# rails generate rolify:role

  create  app/models/role.rb
  insert  app/models/user.rb
  create  config/initializers/rolify.rb
  create  db/migrate/20140128165256_rolify_create_roles.rb

An initializer file has been created here: config/initializers/rolify.rb, you
can change rolify settings to match your needs.
Defaults values are commented out.

A Role class has been been created in app/models (with the name you gave as
argument otherwise the default is role.rb), you can add your own business logic
inside.

Inside your User class (or the name you gave as argument otherwise the default
is user.rb), rolify method has been inserted to provide rolify methods.

Now, if you just have to run the migration using rake command:

   rake db:migrate

and you will be able to add the resourcify method inside all models you want
scoped by a role.

# Copy Devise views into app - rails g devise:views

invoke  Devise::Generators::SharedViewsGenerator
create    app/views/devise/shared
create    app/views/devise/shared/_links.erb
invoke  form_for
create    app/views/devise/confirmations
create    app/views/devise/confirmations/new.html.erb
create    app/views/devise/passwords
create    app/views/devise/passwords/edit.html.erb
create    app/views/devise/passwords/new.html.erb
create    app/views/devise/registrations
create    app/views/devise/registrations/edit.html.erb
create    app/views/devise/registrations/new.html.erb
create    app/views/devise/sessions
create    app/views/devise/sessions/new.html.erb
create    app/views/devise/unlocks
create    app/views/devise/unlocks/new.html.erb
invoke  erb
create    app/views/devise/mailer
create    app/views/devise/mailer/confirmation_instructions.html.erb
create    app/views/devise/mailer/reset_password_instructions.html.erb
create    app/views/devise/mailer/unlock_instructions.html.erb

# rake db:migrate

==  DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
   -> 0.0033s
-- add_index(:users, :email, {:unique=>true})
   -> 0.0005s
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0004s
==  DeviseCreateUsers: migrated (0.0044s) =====================================

==  RolifyCreateRoles: migrating ==============================================
-- create_table(:roles)
   -> 0.0007s
-- create_table(:users_roles, {:id=>false})
   -> 0.0003s
-- add_index(:roles, :name)
   -> 0.0003s
-- add_index(:roles, [:name, :resource_type, :resource_id])
   -> 0.0004s
-- add_index(:users_roles, [:user_id, :role_id])
   -> 0.0004s
==  RolifyCreateRoles: migrated (0.0023s) =====================================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.