Skip to content

Latest commit

 

History

History
72 lines (36 loc) · 3.22 KB

README.rdoc

File metadata and controls

72 lines (36 loc) · 3.22 KB

foxinator-generator

The foxinator-generator lets you quickly get HitFox projects off the ground. It comes with three installation options: a basic admin controller system, a CMS with roles & permissions, and a CMS with admin comments. Of course, you can install all three too. It also gives you a custom scaffold to generate admin-area models.

Installation

Include the gem in your gemfile:

gem "foxinator-generator", git: "[email protected]:HitFox/foxinator-generator.git"

Then answer y or n to the prompts.

Features

The foxinator-generator uses the Comfortable Mexican Loveseat, Devise, and the inherited_resource and state_machine gems. The basic structure is an Admin namespace, which has a BaseController. All future admin-area controllers will inherit from this BaseController. The BaseController comes with a set of default views which will be automatically inherited by all sub-controllers, making your code more DRY.

There is also a basic tooltip functionality built into the CMS. If you want to add a tool tip to a table head, simply expand the th tag like this:

= th(:some_field, title_suffix: tooltip('MY TOOLTIP TEXT', placement: :right)

By default the placement is :top, but you can overwrite it.

Usage

In your rails app run bundle install then to create your admin namespace:

rails g foxinator:setup

This will install Devise and Comfortable Mexican Sofa and all other required dependencies for your admin area!

It will automatically create an admin account with email “[email protected]” and password “password”.

Then change the config.sign_out_via in devise.rb to :get.

If you want to specify a default site, uncomment line 10 in i18n.rb

Now if you want to create an admin-area controller using the foxinator-generator you can:

rails g foxinator:scaffold MyModel name:string

Which will automatically create the model and controller files (inheriting from BaseController) and some default views.

Last step: Edit the permitted params in your controller file!

That’s it! You should now have a basic app up and running!

The foxinator:scaffold Command

When you create a new admin-area controller and model using the foxinator:scaffold command there are a few additional steps to keep in mind.

To begin with, you need to customize your views and strong params.

If you have Comments in your project, you have to add your model to line 35 in the comments_controller.rb like so:

belongs_to :admin, :role, :my_new_model, polymorphic: true

Then also add this line to your model.rb file: include Commentable

Finally, in routes you need to add concerns: [:commentable] and then click the “Sync Roles & Permissions” button under Admin>Roles in the CMS admin page.

foxinator:scaffold:controller & foxinator:scaffold:model

If you just want to create a controller file and views, use foxinator:scaffold:controller Example. If you just need a model, use foxinator:scaffold:model MyModel.

Please note that both of these commands create admin-namespaced classes.

Changelog