Skip to content

Commit

Permalink
Stop bypassing cancan
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Mar 4, 2012
1 parent bacfe92 commit 3536cdc
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ group :development, :test do
end end
end end


gem 'cancan'
gem 'bson_ext' gem 'bson_ext'
gem 'mongoid' gem 'mongoid'
gem 'cancan'
end end


group :debug do group :debug do
Expand Down
4 changes: 0 additions & 4 deletions lib/rails_admin/adapters/active_record.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ def serialized_attributes
model.serialized_attributes model.serialized_attributes
end end


def accessible_by(*args)
model.accessible_by(*args)
end

private private


def query_conditions(query, fields = config.list.fields.select(&:queryable?)) def query_conditions(query, fields = config.list.fields.select(&:queryable?))
Expand Down
6 changes: 1 addition & 5 deletions lib/rails_admin/adapters/mongoid.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -118,17 +118,13 @@ def table_name
def serialized_attributes def serialized_attributes
@serialized_attributes ||= Hash[model.fields.map do |name, field| @serialized_attributes ||= Hash[model.fields.map do |name, field|
if ['Array', 'Hash'].include? field.type.to_s if ['Array', 'Hash'].include? field.type.to_s
[name.to_s, ::ActiveRecord::Coders::YAMLColumn.new(field.type)] # for compatibility [name.to_s, nil] # TODO: support Coder
else else
nil nil
end end
end.compact] end.compact]
end end


def accessible_by(*args)
scoped
end

private private


def query_conditions(query, fields = config.list.fields.select(&:queryable?)) def query_conditions(query, fields = config.list.fields.select(&:queryable?))
Expand Down
4 changes: 0 additions & 4 deletions lib/rails_admin/adapters/mongoid/abstract_object.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ def #{name.to_s.singularize}_ids=(items)
end end
end end


def attributes=(attributes)
object.send :attributes=, attributes
end

def destroy def destroy
object.destroy object.destroy
object object
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_admin/extensions/cancan/authorization_adapter.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def authorized?(action, abstract_model = nil, model_object = nil)
# and bulk_delete/destroy actions and should return a scope which limits the records # and bulk_delete/destroy actions and should return a scope which limits the records
# to those which the user can perform the given action on. # to those which the user can perform the given action on.
def query(action, abstract_model) def query(action, abstract_model)
abstract_model.accessible_by(@controller.current_ability, action) abstract_model.model.accessible_by(@controller.current_ability, action)
end end


# This is called in the new/create actions to determine the initial attributes for new # This is called in the new/create actions to determine the initial attributes for new
Expand Down

2 comments on commit 3536cdc

@bbenezech
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some changes in active_record.rb. To spare you any useless hassle, I merged master into your branch on sferik/mongoid.

Thanks for your hard work.

@mshibuya
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll take a look later on.
Thanks!

Please sign in to comment.