<commit_before>
- create new rails project without test unit `rails new my_app -T`
- `git init; git add .; git commit -m "initial commit"`
- add bitbucket project & push up
- [uninstall turbolink](http://blog.steveklabnik.com/posts/2013-06-25-removing-turbolinks-from-rails-4)

# Setting up Gems

1. Install the Devise gem. See their [Getting Started](https://github.com/plataformatec/devise#getting-started) guide.

We need to customise the Devise files. In `config/initializers/devise.rb`.

- Set the `config.scoped_views` to `true`.
- Set the `config.default_scope` to `administrator`.

2. Install the BBL admin gem. Via the command:
    `gem 'bbl_admin', github: 'joshuapaling/bbl_admin', tag: 'vx.x.x`

You should probably specify a tag until the gem gets into a stable release.

(If you want to read more about installing gems from git repos. Check out the bundler guide: http://bundler.io/git.html).

# Generating the models and controllers

# Admin Model
1. Run `rails generate devise Administrator` to set up the administrator model.
2. Run the migrations `rake db:migrate`.
3. Remove `:registerable` option from `administrator.rb`.

# Controller

Generate controllers like so:

    rails generate controller namespace_name/controller_name

Use `admin` for the `namespace_name`. This will generate the admin folder and views. It will also add the admin namespace to the routes.rb file.

# Copying same files over

Copy the `administrators_controller.rb` and `base_controller.rb` file to the current project `controller/` directory.

Copy the `view/admin/administrators` folder into the project `view/admin` directory.

Add the `administrator` route to `routes.rb`

Copy the `layouts/admin` folder and the `admin.html.erb` file over to your current projects `layout/` folder.

Copy the `js/admin` files across to the current project.

Make sure whatever your route controller is inherits from `Admin::BaseController` rather than application controller. You know if it's inheriting from application controller if your footer and header is the same as the front end. *(probably need to rewrite this sentence)*

# Other stuff

Add a flag to precompile additional assets.

    Rails.application.config.assets.precompile += %w(
      admin.css
      admin.js
    )

You will need to edit the admin top bar to fit the menu for your project.
<commit_msg>Make devise admin steps clearer<commit_after>
- create new rails project without test unit `rails new my_app -T`
- `git init; git add .; git commit -m "initial commit"`
- add bitbucket project & push up
- [uninstall turbolink](http://blog.steveklabnik.com/posts/2013-06-25-removing-turbolinks-from-rails-4)

# Setting up Gems

1. Install the Devise gem. See their [Getting Started](https://github.com/plataformatec/devise#getting-started) guide.

We need to customise the Devise files. In `config/initializers/devise.rb`.

- Set the `config.scoped_views` to `true`.
- Set the `config.default_scope` to `administrator`.

2. Install the BBL admin gem. Via the command:
    `gem 'bbl_admin', github: 'joshuapaling/bbl_admin', tag: 'vx.x.x`

You should probably specify a tag until the gem gets into a stable release.

(If you want to read more about installing gems from git repos. Check out the bundler guide: http://bundler.io/git.html).

# Generating the models and controllers

## Generating Admin model and controller

### Model
1. Run `rails generate devise Administrator` to set up the administrator model.
2. Run the migrations `rake db:migrate`.
3. Remove `:registerable` option from `administrator.rb`.

### Controller

Generate controllers like so:

    rails generate controller namespace_name/controller_name

Use `admin` for the `namespace_name`. This will generate the admin folder and views. It will also add the admin namespace to the routes.rb file.

### Plugging the admin model into bbl admin area

Assuming you have already generated controllers/views with the bbl_admin gem.

1. Copy the `controllers/administrators_controller.rb` file to `controllers/admin` directory.
2. Copy the `views/administrators` folder into `views/admin` directory.

Make sure whatever your route controller is inherits from `Admin::BaseController` rather than application controller. You know if it's inheriting from application controller if your footer and header is the same as the front end. *(probably need to rewrite this sentence)*

# Other stuff

Add a flag to precompile additional assets.

    Rails.application.config.assets.precompile += %w(
      admin.css
      admin.js
    )

You will need to edit the admin top bar to fit the menu for your project.

{'fraction_non_alphanumeric': 0.08295429932856833, 'fraction_numerical': 0.00649772579597141, 'mean_word_length': 4.18876404494382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5172359', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1295, 'n_words': 577}