Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for edgecase with magic attributes #516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/dragonfly/model/attachment_class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def magic_attributes
@magic_attributes ||= begin
prefix = attribute.to_s + '_'
model_class.public_instance_methods.inject([]) do |attrs, name|
_, __, suffix = name.to_s.partition(prefix)
if !suffix.empty? && allowed_magic_attributes.include?(suffix.to_sym)
pre_prefix, __, suffix = name.to_s.partition(prefix)
if !suffix.empty? && pre_prefix.empty? && allowed_magic_attributes.include?(suffix.to_sym)
attrs << suffix.to_sym
end
attrs
Expand Down
4 changes: 4 additions & 0 deletions spec/dragonfly/model/model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@
) do
dragonfly_accessor :preview_image
dragonfly_accessor :other_image

def method_about_other_image_size
fail "This should not be called"
end
end
@item = @item_class.new
end
Expand Down