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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior when frozen? method is defined in model #918

Open
kenzo-tanaka opened this issue Apr 19, 2022 · 1 comment
Open

Unexpected behavior when frozen? method is defined in model #918

kenzo-tanaka opened this issue Apr 19, 2022 · 1 comment

Comments

@kenzo-tanaka
Copy link

kenzo-tanaka commented Apr 19, 2022

Hi馃憢
First of all thank you for the very helpful gem!
I found an unexpected behavior while using draper and would like to report it.
When the frozen? method is defined in the model, the decorated instance returns false.

The following is a sample code.

# app/models/user.rb

class User < ApplicationRecord
  def frozen?
    true
  end
end
class UserDecorator < Draper::Decorator
  delegate_all
end
rails console
irb(main):001:0> User.first.decorate.frozen?
   (1.2ms)  SELECT sqlite_version(*)
  User Load (0.2ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT ?  [["LIMIT", 1]]
=> false  # expected true

https://github.com/kenzo-tanaka/tmp_draper

I'm sorry if I misunderstood something about this behaviour馃檹

@itzbernoulli
Copy link

Hi @kenzo-tanaka seems this is a ruby thing rather than a draper issue. If you call frozen? on the object without decorating it still returns false as long as you didn't freeze the object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants