Sha256: 1926aa013745ec9bccd6ea9e0339c313709b0f4d6334342142412b23ea4e70ac

Contents?: true

Size: 391 Bytes

Versions: 1

Compression:

Stored size: 391 Bytes

Contents

module RestfulController
  module Filters
    extend ActiveSupport::Concern
    included do
      # set_post
      define_method "set_#{model_name}" do
        model = self.class.model_class.find(params[:id])
        instance_variable_set("@#{self.class.model_name}", model)
      end

      append_before_filter "set_#{model_name}", only: [:show, :edit, :update, :destroy]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restful-controller-0.0.3 lib/restful_controller/filters.rb