Sha256: 4c5101fa448004a94b3048cefcd33c04ff95eb5f9bf1f9163b7807a2768175d1
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
class RowsController < ApplicationController require_dependency 'rows_controller/helpers' respond_to :html, :xml def index respond_with(resources) end def show respond_with(resource) end def new respond_with(resource) end def edit respond_with(resource) end def create # merge_bag msg = t('ui.created', :model => model_name, :default => "%{model} created.") save_and_respond(msg, 'rows/new') end def update # merge_bag msg = t('ui.updated', :model => model_name, :default => "%{model} updated.") save_and_respond(msg, 'rows/edit') end def destroy resource.destroy respond_with(resource) do |format| format.html { redirect_to :action => :index } format.js { render :template => 'rows/destroy' } end flash[:notice] = t('ui.deleted', :model => model_name, :default => "%{model} deleted.") end def copy @_resource = resource.dup @_resource.id = nil respond_with(resource) do |format| format.html { render :action => :new } end end private def save_and_respond(notice, failure_template) if resource.save respond_with(resource) do |format| format.html { redirect_to :action => :edit, :id => resource.id } format.xml { render :xml => resource.errors, :status => :unprocessable_entity } end flash[:notice] = notice else respond_with(resource) do |format| format.html { render :template => failure_template, :id => resource.id } format.xml { render :xml => resource.errors, :status => :unprocessable_entity } end end end # May be useful: # def multi_deletion # items = params[:multi_deletion] || [] # items -= [''] # items.map {|id| model_class.find(id).destroy } # redirect_to :action => :index # end # def merge_bag # self.params = model_class.merge({}, self.params) if model_class.respond_to?(:merge) # end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rows_controller-0.3.2 | app/controllers/rows_controller.rb |