Sha256: 0f12d3d30d75d4520ce4199bd3dce18d8fd350d768015e43b212967c620074fe
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
class <%= controller_class_name %>Controller < ApplicationController <% if nested_to_class %>before_filter :find_<%= nested_to_class %><% end %> # GET /<%= plural_name %> def index @<%= plural_name %> = <%= nested_to_class ? "@#{nested_to_class}.#{ plural_name}" : "#{model_name}.all" %> end # GET /<%= plural_name %>/1 def show @<%= file_name %> = <%= model_name %>.find(params[:id]) end # GET /<%= plural_name %>/new def new @<%= file_name %> = <%= nested_to_class ? "@#{nested_to_class}.#{plural_name}.new" : "#{ model_name}.new" %> end # GET /<%= plural_name %>/1/edit def edit @<%= file_name %> = <%= model_name %>.find(params[:id]) end # POST /<%= plural_name %> def create @<%= file_name %> = <%= nested_to_class ? "@#{nested_to_class}.#{plural_name}.build" : "#{model_name}.new" %>(params[:<%= file_name %>]) if @<%= file_name %>.save flash[:notice] = '<%= model_name %> was successfully created.' redirect_to <%= object_path("@#{file_name}") %> else render :action => "new" end end # PUT /<%= plural_name %>/1 def update @<%= file_name %> = <%= model_name %>.find(params[:id]) if @<%= file_name %>.update_attributes(params[:<%= file_name %>]) flash[:notice] = '<%= model_name %> was successfully updated.' redirect_to <%= object_path("@#{file_name}") %> else render :action => "edit" end end # DELETE /<%= plural_name %>/1 def destroy @<%= file_name %> = <%= model_name %>.find(params[:id]) @<%= file_name %>.destroy redirect_to <%= index_path %> end <% if nested_to_class %> protected def find_<%= nested_to_class %> @<%= nested_to_class %> = <%= nested_to_class.camelcase %>.find(params[:<%= nested_to_class %>_id]) end <% end %> end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
handy-generators-0.0.2 | rails_generators/hscaffold/templates/controller.rb |
handy-generators-0.0.1 | rails_generators/hscaffold/templates/controller.rb |