Scoped Access plugin

Plugin details

Nested Scope Access

Repositoryhttp://wota.jp/svn/rails/plugins/trunk/scoped_access/ Tags scope LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install http://wota.jp/svn/rails/plugins/trunk/scoped_access/

Usage Example
==============

class ActiveMember
  class ActiveMemberController
    around_filter ScopedAccess::Filter.new(Member, Scopings::ActiveMember)

    def nested_scoping_with_elementary_school
      Member.with_scope(Scopings::ElementarySchool) do
        @members = Member.find(:all)
      end
      render :text=>''
    end
  end

  def setup
    super
    @controller = ActiveMemberController.new
  end

  def filter_list
    get :list
    assert_response :success
    expected = %w( saki yurina risako airi ).collect{|name| members(name)}
    assert_equal expected, @controller.members
  end

  def filter_show
    assert_raises(ActiveRecord::RecordNotFound) {
      get :show, {'id' => "2"}
    }
  end

  def filter_nested_scoping
    get :nested_scoping_with_elementary_school
    assert_response :success
    assert_equal [members(:yurina), members(:risako)], @controller.members
  end
end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: hardway, 8 months ago