Skip to content

Commit

Permalink
Passing class instances as ActiveRecord attributes is deprecated in R…
Browse files Browse the repository at this point in the history
…ails 5
  • Loading branch information
cbeer committed Dec 18, 2015
1 parent 6004cd5 commit 8ccebc8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/blacklight/bookmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def create
# Beware, :id is the Solr document_id, not the actual Bookmark id.
# idempotent, as DELETE is supposed to be.
def destroy
bookmark = current_or_guest_user.bookmarks.find_by(document_id: params[:id], document_type: blacklight_config.document_model)
bookmark = current_or_guest_user.bookmarks.find_by(document_id: params[:id], document_type: blacklight_config.document_model.to_s)

if bookmark && bookmark.delete && bookmark.destroyed?
if request.xhr?
Expand Down
4 changes: 3 additions & 1 deletion app/models/bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def document
end

def document_type
(super.constantize if defined?(super)) || default_document_type
value = super if defined?(super)
value &&= value.constantize
value ||= default_document_type
end

def default_document_type
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/blacklight/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.included(base)

def bookmarks_for_documents documents = []
if documents.length > 0
bookmarks.where(document_type: documents.first.class.base_class, document_id: documents.map(&:id))
bookmarks.where(document_type: documents.first.class.base_class.to_s, document_id: documents.map(&:id))
else
[]
end
Expand Down

0 comments on commit 8ccebc8

Please sign in to comment.