Sha256: 7e1a10ae890886261de17fb3337a1be32fe5e73e0db860df23f9e247b670df40
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'ApplicationController' %> def index @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page] respond_to do |format| format.html format.js end end def show @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id]) render :layout => false end def new @<%= @model.singular_name %> = <%= @model.klass %>.new render :layout => false end def edit @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id]) render :layout => false end def create @<%= @model.singular_name %> = <%= @model.klass %>.new(params[:<%= @model.object_name %>]) @system_notice = t('<%= @model.plural_name %>.create_success') if @<%= @model.singular_name %>.save # loads all <%= @model.plural_name %> to display in the list load_list respond_to do |format| format.js end end def update @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id]) @system_notice = t('<%= @model.plural_name %>.update_success') if @<%= @model.singular_name %>.update_attributes(params[:<%= @model.object_name %>]) # loads all <%= @model.plural_name %> to display in the list load_list respond_to do |format| format.js end end def destroy @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id]) @system_notice = t('<%= @model.plural_name %>.destroy_success') if @<%= @model.singular_name %>.destroy # loads all <%= @model.plural_name %> to display in the list load_list respond_to do |format| format.js end end private def load_list @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => 1 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mdd-2.0.1 | lib/generators/mdd/scaffold/templates/controllers/ajax_controller.rb |
mdd-2.0 | lib/generators/mdd/scaffold/templates/controllers/ajax_controller.rb |