Sha256: 28eca95f124ba310dd3b256bbb4633051cc3f5f9c30b0267e1075ceeff5ac63c
Contents?: true
Size: 1.3 KB
Versions: 6
Compression:
Stored size: 1.3 KB
Contents
class <%= controller_class_name %>Controller < ApplicationController before_action :set_<%= singular_table_name %>, only: %i[show edit update destroy] def index @<%= plural_table_name %> = <%= class_name %>.all end def show end def new @<%= singular_table_name %> = <%= class_name %>.new end def edit end def create @<%= singular_table_name %> = <%= class_name %>.new(<%= singular_table_name %>_params) if @<%= singular_table_name %>.save redirect_to @<%= singular_table_name %>, notice: '<%= human_name %> was successfully created.' else render :new end end def update if @<%= singular_table_name %>.update(<%= singular_table_name %>_params) redirect_to @<%= singular_table_name %>, notice: '<%= human_name %> was successfully updated.' else render :edit end end def destroy @<%= singular_table_name %>.destroy redirect_to <%= index_helper %>_url, notice: '<%= human_name %> was successfully destroyed.' end private def set_<%= singular_table_name %> @<%= singular_table_name %> = <%= class_name %>.find(params[:id]) end def <%= singular_table_name %>_params params.require(:<%= singular_table_name %>).permit(<%= (attributes + %i[start_id end_id]).map { |attr| ":#{attr.name}" }.join(', ') %>) end end
Version data entries
6 entries across 6 versions & 1 rubygems