Skip to content
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
2 changes: 1 addition & 1 deletion lib/active_hash/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def exists?(args = :none)
elsif args.is_a?(Hash)
all.where(args).present?
else
all.where(id: args.to_i).present?
all.where(id: args.to_s).present?
end
end

Expand Down
10 changes: 10 additions & 0 deletions spec/active_hash/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,16 @@ def continent
end
end
end

context "when ids are strings" do
before do
Country.all.each { |c| c.id = c.name }
end

it "return true" do
expect(Country.exists?("Canada")).to be_truthy
end
end
end

describe "#method_missing" do
Expand Down