Paper_Trail和CanCan:Rails_Admin不显示版本

时间:2015-06-03 19:50:30

标签: ruby-on-rails cancan rails-admin paper-trail-gem

我在Rails应用程序中配置了Paper_Trail和CanCan。 Rails_Admin很好地向我展示了表versionsversion_associations

在另一个应用程序(实际上是前一个应用程序的分支)中,我希望Rails_Admin也能显示这些表,但事实并非如此。

在这两个应用程序中,我以角色admin的用户身份登录,两个应用程序的功能如下所示:

class Ability
  include CanCan::Ability

  def initialize(current_user)
    alias_action :create, :read, :update, :destroy, to: :crud

    can :read, User

    if current_user.nil?
      can :create, User
    else
      can :update, User do |user|
        user == current_user # Update himself
      end

      can :crud, Boilerplate # This is the only line that the 2nd app adds to the ability

      if current_user.has_role?(:admin)
        can :access, :rails_admin
        can :dashboard

        can :crud, :all
      end

      cannot :destroy, User do |user|
        user == current_user
      end
    end
  end
end

除了can :crud, Boilerplate行之外,一切都是一样的。迁移也是一样的,所以我有所需的表等。

我创建了每个应用current_ability的转储:diff on diffchecker.com。我可以看到,在Rails_Admin中看到Paper_Clip内容的用户有很多@expanded_actions,而另一个没有。{这可能来自哪里?两个用户肯定都有:admin角色。

1 个答案:

答案 0 :(得分:0)

问题是我没有使用最新的paper_trail版本(版本import static com.querydsl.core.alias.Alias.* Foo foo = alias(Foo.class, "foo"); assertThat($(foo.getBar().getBaz()).getMetaData().getName()).isEqualTo("foo.bar.baz"); )。

相关问题