Sha256: 0a0d7ca8b3d552e8062cb0f9d2b3d1dccee49d315a512fb1d94cc2526529f12a
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
class <%= controller_class_name %>Controller < ApplicationController <% unless suffix -%> def index end <% end -%> <% for action in unscaffolded_actions -%> def <%= action %><%= suffix %> end <% end -%> def list<%= suffix %> @<%= plural_name %> = <%= model_name %>.find :all render :layout => false end def new<%= suffix %> @<%= singular_name %> = <%= model_name %>.new @temp_id = Time.new.to_i @headers['<%= singular_name %>-id'] = @temp_id @headers['Content-Type'] = 'text/html; charset=utf-8' render :layout => false # If you want to send an error message: # render :inline => "Error text goes here", :layout => false, :status => 500 end def create<%= suffix %> @<%= singular_name %> = <%= model_name %>.new(params[:<%= singular_name %>]) if @<%= singular_name %>.save @headers['<%= singular_name %>-id'] = @<%= singular_name %>.id @headers['Content-Type'] = 'text/html; charset=utf-8' render :partial => '<%= singular_name %><%= suffix %>', :layout => false, :locals => { :hidden => true } else render :partial => 'form_errors', :layout => false, :status => 500 end end def edit<%= suffix %> @<%= singular_name %> = <%= model_name %>.find(params[:id]) render :layout => false end def update @<%= singular_name %> = <%= model_name %>.find(params[:id]) if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>]) render :partial => '<%= singular_name %><%= suffix %>', :layout => false, :locals => { :hidden => true } else render :partial => 'form_errors', :layout => false, :status => 500 end end def destroy<%= suffix %> <%= model_name %>.find(params[:id]).destroy render :nothing => true end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
ajax_scaffold_generator-2.1.0 | templates/controller.rb |
ajax-scaffold-generator-2.1.0 | templates/controller.rb |