No release in over a year
This is a patch that modifies the rails g scaffold_controller generator to accept a --with_attributes option. The --with_attributes option is used to read model attributes if none are specified on the command line. This is a way to simplify the process of generating code by automatically including all of the attributes of the model when generating controller actions and views.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 5.0.0
 Project Readme

Overview

This gem adds a --with-attributes option to the rails g command, specifically for the rails g scaffold_controller command. This is useful because by default the command doesn't generate the controller actions and views / form fields for the fields that exist on the model. I find this particularly annoying because it pretty much renders the generator useless for my needs, which were to build an admin interface for some select models. This gem monkey patches Rails::Generators::NamedBase to looks for the the --with_attributes options and if present, include the model fields automatically for the invoked generator. I haven't tested this for generators other than scaffold_controller, so use at your own risk for anything else.

Installation

Add the following to your Gemfile:

group :development do
  # ...
  gem 'rails_g_with_attributes'
  # ...
end

Usage

Append the --with-attributes option to the rails g scaffold_controller command. For example:

rails g scaffold_controller Admin::Users --model-name=User --with-attributes`

will generate the namespaced controller and views for the User model, including the form fields for the model's attributes.

Publishing

  1. Update the version in rails_g_with_attributes.gemspec
  2. Generate a new version with gem build rails_g_with_attributes.gemspec
  3. Push the new version to rubygems with gem push rails_g_with_attributes-<version>.gem
  4. Update Github with the new version code