Last active
August 29, 2015 14:16
-
-
Save buyaka/c9c74e0ba2ef3948a144 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #rails new <APPNAME> -T -m app_template.rb -d mysql | |
| source_paths << File.dirname(__FILE__) | |
| gem 'devise' | |
| gem 'cancan' | |
| gem 'mysql2' | |
| gem 'therubyracer', platforms: :ruby | |
| gem "twitter-bootstrap-rails" | |
| gem 'bootstrap-material-design' | |
| #gem 'unicorn' | |
| #gem 'capistrano-rails', group: :development | |
| #gem 'rspec-rails', '~> 3.0', group: :development | |
| run 'bundle install' | |
| # Read me | |
| run 'rm README.rdoc' | |
| file 'README.md', <<-README | |
| ## Template for rapid Rails prototypes | |
| * Rails 4 | |
| * No tests / specs | |
| * Bootstrap | |
| README | |
| # DB config | |
| run 'rm config/database.yml' | |
| file 'config/database.yml', <<-DATABASE | |
| development: | |
| adapter: mysql2 | |
| encoding: utf8 | |
| pool: 5 | |
| host: localhost | |
| database: app_dev | |
| username: root | |
| password: root | |
| test: | |
| adapter: mysql2 | |
| encoding: utf8 | |
| pool: 5 | |
| host: localhost | |
| database: app_test | |
| username: root | |
| password: root | |
| production: | |
| adapter: mysql2 | |
| encoding: utf8 | |
| pool: 5 | |
| host: localhost | |
| database: app | |
| username: root | |
| password: root | |
| DATABASE | |
| # Bootstrap | |
| generate "bootstrap:install", "static" | |
| generate "bootstrap:layout", "application", "fluid" | |
| # Templates | |
| file 'app/views/shared/_errors.html.erb', <<-ERRORS | |
| <% if object.errors.any? %> | |
| <div class="alert alert-error"> | |
| <a class="close" data-dismiss="alert">×</a> | |
| <ul> | |
| <% object.errors.full_messages.each do |msg| %> | |
| <%= content_tag :li, msg %> | |
| <% end %> | |
| </ul> | |
| </div> | |
| <% end %> | |
| ERRORS | |
| # Authentication | |
| generate "devise:install" | |
| generate "devise member" | |
| # Views | |
| generate " devise:views" | |
| # Devise member role migration | |
| generate 'migration add_role_to_members role' | |
| generate 'cancan:ability' | |
| # Role add into member | |
| run 'rm app/models/member.rb' | |
| file 'app/models/member.rb', <<-MEMBERINFO | |
| class AdminUser < ActiveRecord::Base | |
| # Include default devise modules. Others available are: | |
| # :confirmable, :lockable, :timeoutable and :omniauthable | |
| devise :database_authenticatable, :registerable, | |
| :recoverable, :rememberable, :trackable, :validatable | |
| ROLE = {admin: "admin", member: "member"} | |
| end | |
| MEMBERINFO | |
| #Make ability | |
| run 'rm app/models/ability.rb' | |
| file 'app/models/ability.rb', <<-DEF | |
| class Ability | |
| include CanCan::Ability | |
| def initialize(user) | |
| if user.admin? | |
| can :admin, :all | |
| elsif user.member? | |
| can :member, :all | |
| end | |
| end | |
| end | |
| DEF | |
| # Route | |
| route 'root to: "welcome#index"' | |
| # Git | |
| git :init | |
| git add: "." | |
| git commit: "-a -m 'Created from app template'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment