Sha256: acba5224f9d3e34b7144a4e54f5700dc81057e07980797df8c9edb4fdbfe7daa

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

class <%= plural_class_name %>Controller < ApplicationController

<%- if actions_with_find.length > 0 -%>
  before_filter :find_<%= singular_name %>, :only => [ <%= actions_with_find.collect{|a| ":#{a}"}.join(', ') %> ]
<%- end -%>

  <%= controller_methods :actions %>

<%- if actions_with_find.length > 0 -%>
  protected

  def find_<%= singular_name %>
    @<%= singular_name %> = <%= class_name %>.find(params[:id])
  rescue ActiveRecord::RecordNotFound => msg
    flash[:error] = msg
    <%- if action?(:index) -%>
      redirect_to :action => :index
    <%- else -%>
      redirect_to root_path
    <%- end -%>
  end
<%- end -%>
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
splendeo-generators-0.2.1 rails_generators/splendeo_scaffold/templates/controller.rb