These are chat archives for dry-rb/chat

27th
Jun 2018
Piotr Solnica
@solnic
Jun 27 2018 09:37
as long as gems are < 1.0, switching versions in docs is not needed
tbh, moving docs to individual project repos is a more important to-do at the moment
Igor S. Morozov
@Morozzzko
Jun 27 2018 10:15

Alright, no need to add versions right now. Thank you!

I’ll add CI within two weeks, that should help with moving docs to individual repos.

dry-rb.org is hosted on Heroku, right?

Nikita Shilnikov
@flash-gordon
Jun 27 2018 10:23
it’s hosted on GH
wrt, CI I know @davydovanton has a solution for this
I believe you can ping him
Jaromír Červenka
@Cervajz
Jun 27 2018 10:29
Re CI - I can offer virtual servers if needed (hdd/ssd, 1Gbs, IPv4/IPv6) in central europe
Igor S. Morozov
@Morozzzko
Jun 27 2018 10:34

Oh, I see. Thought it was hosted on GH Pages first, but then noticed the Procfile. This stuff is confusing

Thanks for the heads up, I’ll talk to Anton

Jaromír Červenka
@Cervajz
Jun 27 2018 17:42
Hello :) I am testing example of scoped_unique? from http://dry-rb.org/gems/dry-validation/comparison-with-activemodel/ but I am not successful. Can you see anything I may have missed, please? I am unable to get three arguments to the scoped_unique? method.
module Users
  UserSchema = Dry::Validation.Schema do
    configure do
      option :record

      def scoped_unique?(attr_name, scope, value)
        record.class.where.not(id: record.id).where(scope).where(attr_name => value).empty?
      end
    end

    required(:email).filled(scoped_unique?: [:email, { active: true }])
  end
end
[7] pry(main)> reload!; Users::UserSchema.with(record: User.new).call({email: "admin@example.com"})
Reloading...
ArgumentError: wrong number of arguments (given 2, expected 3)
from /Users/cervajz/Projects/Personal/Ruby/virtio/api/app/schemas/users/user_schema.rb:6:in `scoped_unique?'
[8] pry(main)>
Jaromír Červenka
@Cervajz
Jun 27 2018 17:51
When changed to method with just two arguments:
[3, 12] in /Users/cervajz/Projects/Personal/Ruby/virtio/api/app/schemas/users/user_schema.rb
    3:     configure do
    4:       option :record
    5:
    6:       def scoped_unique?(attr_name, value)
    7:         byebug
=>  8:         record.class.where.not(id: record.id).where(scope).where(attr_name => value).empty?
    9:       end
   10:     end
   11:
   12:     required(:email).filled(scoped_unique?: [:email, { active: true }])
(byebug) attr_name
[:email, {:active=>true}]
(byebug) value
"admin@example.com"
(byebug)