0.0
No commit activity in last 3 years
No release in over 3 years
Better default templates for Rails scaffold generator.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 5.0.0
~> 2.2.0
 Project Readme

Action Scaffold

Gem Version

  • Clean & DRY Rails controllers.
  • View support for bootstrap 4, uikit, skeleton and html5boilerplate.
  • Select box for a belongs_to relationship.
  • Nested resources
  • HTML5 controls
  • Bootstrap themes

Usage

Controller generator (respond_with by default):

$ rails g responders:install
$ rails g scaffold_controller:install

Result:

class BooksController < ApplicationController
  before_action :set_book,
    only: [:show, :edit, :update, :destroy]

  # GET /books
  def index
    @books = Book.all
    respond_with(@books)
  end

  # GET /books/1
  def show
    respond_with(@book)
  end

  # GET /books/new
  def new
    @book = Book.new
    respond_with(@book)
  end

  # GET /books/1/edit
  def edit
  end

  # POST /books
  def create
    @book = Book.new(book_params)
    @book.save
    respond_with(@book)
  end

  # PATCH/PUT /books/1
  def update
    @book.update(book_params)
    respond_with(@book)
  end

  # DELETE /books/1
  def destroy
    @book.destroy
    respond_with(@book)
  end

  private

  def set_book
    @book = Book.find(params[:id])
  end

  def book_params
    params.require(:book).
      permit(:title, :author)
  end
end

Bootstrap

View generator (Bootstrap by default):

$ rails g scaffold_view:install

Generate application layout

$ rails g layout bootstrap

... or manualy import Bootstrap styles from in app/assets/stylesheets/application.css:

// app/assets/stylesheets/application.scss
 *= require "bootstrap/bootstrap.min"
 *= require "bootstrap/bootstrap-theme.min"

Results:

<div class="form-group">
  <%= f.label :email %>
  <%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>

new

Index

![Errors](http://i63.tinypic.com/302b22f.png =600x "Errors")

![Forms](http://i66.tinypic.com/349b0og.png =600x "Forms")

Skeleton

$ rails g scaffold_view:install skeleton

Generate application layout with or without css files

$ rails g layout skeleton 

... or manualy import skeleton styles in app/assets/stylesheets/application.css:

/*
 *= require "skeleton/normalize"
 *= require "skeleton/skeleton"
 */

Results: Form

Index

Installation

Add this line to your application's Gemfile:

gem 'responders'  # (optional) Add this if you want to use scaffold_controller
gem 'actionscaffold'

And then execute:

$ bundle

Or install it yourself as:

$ gem install actionscaffold

To do

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mtunjic/actionscaffold.

License

The gem is available as open source under the terms of the MIT License.