-
Notifications
You must be signed in to change notification settings - Fork 0
How to build this project
Torres edited this page Feb 8, 2018
·
1 revision
name | version | link |
---|---|---|
devise | --- | https://github.com/plataformatec/devise |
rolify | --- | https://github.com/RolifyCommunity/rolify |
authority | --- | https://github.com/nathanl/authority |
devise_ldap_authenticatable | --- | --- |
net-ldap | --- | --- |
omniauth | --- | --- |
audited | --- | https://github.com/collectiveidea/audited |
--- | --- | --- |
ransack | --- | https://github.com/activerecord-hackery/ransack |
will_paginate | --- | https://github.com/mislav/will_paginate |
- make new project
- bundle install
- DB migrate (SQLite / MySQL)
- user rails Console & Server
$ rails new template-Rails-Auth
$ bundle install
$ rails db:migrate
$ rails db:migrate:status
$ rails db:rollback
$ rails s
$ rails c
$ rails routes
- login
- sign up
## devise
$ rails g devise:install
$ rails g devise User
$ rails db:migrate
$ rails g devise:views
$ rails g migration AddColumnUsers username:string
## model
$ rails g scaffold projects
- Role management for user
## role
$ rails g rolify Role
## Auth
$ rails g authority:install
## usage
$ user = User.find_by(username:'1001')
$ user.roles.pluck(:name, :resource_type, :resource_id)
$ user.add_role :admin
$ user.add_role :owner, Project.find(1)
## model
$ rails g scaffold projects
$ rails g scaffold posts
## keyword
belongs_to
has_many
config/initializers/authority.rb
** ProjectAuthorizer, PostAuthorizer
** creatable_by?, updatable_by?, deletable_by?, permissionable_by?
- audit log for resources
## Gemfile
gem "audited", "~> 4.6"
## command
$ rails generate audited:upgrade
$ rake db:migrate
## keyword
audited
has_associated_audits
## Gemfile
gem 'ransack'
config/initializers/ransack.rb
## view helper
<%= search_form_for @q, url: , class: do |f| %>
## controller
@q = Project.ransack(params[:q])
## Gemfile
gem 'will_paginate'
## view helper
<%= will_paginate @projects, :class , :previous_label, :next_label %>
## keyword
lib/pagination.css