No commit activity in last 3 years
No release in over 3 years
Creates controller and extended scaffolding for the model specified.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

ControllerScaffolding

Gem Version

Description

The generator acts somewhat like scaffolding, but you must specify an existing model and pass in any actions you want added (or no actions at all if you want all RESTful actions added). With no options passed in it generates index pages with search/sort* functionality and basic pagination. On the forms it adds optional date/time pickers** and displays flash messages and validation errors. It also adds some styling for the index page and the new/edit form which makes it a bit easier on the eyes until you have a chance to add your own styling.

* https://github.com/jomalley2112/sql_search_n_sort

** https://github.com/jomalley2112/hot_date_rails

Index page

Index

Create/Edit page

Form

Add the following line to your project's Gemfile gem 'controller_scaffolding' and then run bundle install

Usage

Real Example:

$ rails g controller_scaffolding users index new create edit update destroy --template-engine=haml --skip-assets --skip-test-framework --skip-helper

All Options:

$ rails g|d controller_scaffolding plural_model_name action1 action2 action3 --template-engine=erb|haml
[--skip-ext-index-nav] [--skip-ext-form-submit] [--skip-datepicker] [--skip-assets] [--skip-test-framework] [--skip-helper] [--quiet] [--force] [--skip-search-sort]

Note: You must restart Rails after running this generator

Arguments

  1. The name of the existing model (as plural)
  2. A space-separated list of controller actions. If none are specified it will act as if all RESTful actions were specified.

Options

Option Description Optional?
--template-engine Specify template engine...erb or haml (erb is default) yes
--skip-ext-index-nav Do not include extended index navigation functionality yes
--skip-ext-form-submit Do not include extended form submission functionality yes
--skip-datepicker Do not include date/time picker functionality yes
--skip-assets Do not create assets yes
--skip-test-framework Do not create test files yes
--skip-helper Do not create helper file yes
--quiet Suppress info messages yes
--force Overwrite files without prompting yes
--skip-search-sort Do not include search or sort functionality yes

Description of generator actions

Controller

  • Adds functionality to support pagination for the index page if extended index navigation was selected.
  • Creates any of the normal REST actions that were passed to the generator. These actions will have built-in functionality that handles success and validation error messages.
  • Adds a method to handle strong params. This should be reviewed to make sure that all of the params that are allowed, should be allowed.

Application Controller

  • Includes concerns ExtFormSubmit and ExtIndexNav depending on configuration

Concerns

  • installs ext_index_nav.rb if extended index navigation selected
  • installs ext_form_submit.rb if extended form submission selected

Routes

  • Adds get routes for any non-RESTful actions specified
  • Adds a resources line for the model specified. This may be an issue if the routes file already contains entries for the resource

Extended index navigation (optional)

  • Generates an index view file for the model specified containing columns with headers for all fields except id, created_at and updated_at. Certain keywords are given priority when found in the field names which makes them show up before others in the views (eg. name, email)
  • Generates pagination functionality for the index page. Default items per page can be set by editing the @per_page variable in app/controllers/concerns/ext_index_nav.rb
  • Adds some styling to the index page

Extended form submission (optional)

  • Generates a form partial which is utilized by both the new and edit views for the model specified.
  • The form will have input labels and input fields of the proper type prioritized the same way as the index columns
  • The form has two buttons.
    • One button performs the "normal" action of saving and redirecting to the list of resources.
    • The other button Saves and reloads the current page allowing the user to add multiple items without having to go back to the index page each time.
  • Adds functionality to display flash messages and validation errors.
  • Adds some styling to the form

Assets

  • Javascript
    • Installs ext_index_nav.js if extended index navigation is selected.
    • Requires jquery and jquery_ujs in application.js
  • Stylesheets
    • Installs controller_scaffolding.css.scss if either extended index navigation or extended form submission are selected

Search and Sort

Datepicker

  • Uses hot_date_rails to attach date, time and datetime pickers to appropriate form input fields.

Testing

  • Generator tests: run rake test from the root directory.
  • Integration test specs: run rspec spec from 'test/dummy'

Gem dependencies

Dependencies

  • 'rails', '~> 4.1'
  • 'will_paginate'
  • 'haml-rails'
  • 'sass-rails', '~> 4.0.3'
  • 'jquery-rails'
  • 'sql_search_n_sort', '=2.0.2'
  • 'hot_date_rails', '~> 1.4.0'

Development Environment Dependencies

  • "sqlite3"
  • "rspec-rails"
  • "capybara"
  • "selenium-webdriver"
  • "factory_girl_rails"
  • "database_cleaner"

TODO

  • See if we can support case where existing model has been removed after generator has been run and then the user decides to uninstall (revoke) controller_scaffolding.
  • Add search results message like "9 Results match 'you search string'"
  • Nail down versions for dependencies