Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 06:15
    lazebny starred dry-rb/dry-types
  • Feb 19 22:35
    solnic commented #141
  • Feb 19 22:32

    solnic on v0.17.0

    (compare)

  • Feb 19 22:32

    solnic on master

    Bump dry-system to 0.17.0 (compare)

  • Feb 19 22:31

    solnic on 141-fix-compat-with-dry-configurable

    Bump dry-system to 0.17.0 (compare)

  • Feb 19 22:31

    dry-bot on master

    [devtools] update changelog.yml… [devtools] sync (compare)

  • Feb 19 22:27

    solnic on 141-fix-compat-with-dry-configurable

    (compare)

  • Feb 19 22:27

    solnic on master

    Fix compatibility with dry-conf… Merge pull request #142 from dr… (compare)

  • Feb 19 22:27
    solnic closed #142
  • Feb 19 22:27
    solnic closed #141
  • Feb 19 22:24
    solnic milestoned #141
  • Feb 19 22:23
    solnic opened #142
  • Feb 19 22:23

    solnic on 141-fix-compat-with-dry-configurable

    Fix compatibility with dry-conf… (compare)

  • Feb 19 21:12
    flash-gordon commented #141
  • Feb 19 20:45
    jswanner opened #141
  • Feb 19 20:45
    jswanner labeled #141
  • Feb 19 17:38
    pmackay starred dry-rb/dry-monads
  • Feb 19 17:18
    tomraithel starred dry-rb/dry-types
  • Feb 19 11:51
    yingce starred dry-rb/dry-types
  • Feb 19 11:45
    yingce starred dry-rb/dry-types
Lonnie VanZandt
@lonniev
BTW I come to the party without Rails baggage and with no intention of first adopting Rails. Reading a bit, I see that the typical use case for TRB is a developer already using Rails, wanting to improve their situation. I'm in a green field looking for a way to explore dry-web, hoping to avoid ActiveRecord. This is why I'm looking around for the dry-web-roda entity or TRB generators.
Rijul Raut
@mindseyeblind
So I'm in the process of converting my Rails stack to use dry-validations, and I just had one question: how do I handle conditional validations? Do I just use an if block?
Christopher Dennl-Ortega Arrieta
@cdennl
@lonniev Im using Rails + TRB2 + Dry-v, using sequel instead of AR and using Cells instead of AV
Fran Worley
@fran-worley
@lonniev trailblazer is not a framework in itself, rather it's a series of gems - the main ones being Reform - form objects, operations to make sense of business logic and processes (similar to dry transaction) - that you can incorporate what you want and need into your project whatever your framework or ORM. I've got apps in Sinatra that use elements of trailblazer and an app (no framework so to speak) that uses Roda for routing, Sequel as an ORM, dry-validations and types for validations and coercions with trailblazer gems to bring it all together.
@lonniev hey, we won’t have generators for things like entities mostly because dry-web is not a full stack framework that ships with such concepts
we can have generators for some things though, like roda routes or transaction skeletons
Piotr Solnica
@solnic
@lonniev could you start a thread on discuss.dry-rb.org? it’s a better place to ask such questions
Lonnie VanZandt
@lonniev
@solnic sure bye-here
MarkT
@paradisaeidae
Hi dry! Looks like I've got some reading to do here...
Newbie Q: Is there anything such as justinfrench/formtastic#1197 as part of the dry collection? If not are there show stoppers in intergrating them?
Tim Riley
@timriley
@paradisaeidae Looks lke Formtastic is built for Rails. We don’t have our own form builder gem right now, but there are ones like Reform that integrate fairly well with dry-rb gems like dry-validation.
MarkT
@paradisaeidae
Thanks Tim!
Looks like there are some options: "Many are successfully using other ActiveModel-like ORMs and objects (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing full compatibility at this stage. Patches are welcome!"
Christopher Dennl-Ortega Arrieta
@cdennl
@paradisaeidae trailblazer formular is a nice form builder gem which works nicely with dry-v (and reform), I use it by myself and it is developed by @fran-worley
George Millo
@georgemillo
dry-web-roda generate app admin
No value provided for required options '--umbrella'
what is umbrella supposed to be?
ohhh wait I see
the name of my parent app so it knows what namespace to wrap things in
(right?)
George Millo
@georgemillo
second mystery: I managed to generate my Admin app, but couldn't figure out how to actually get it mounted in my roots
got it working now by editing system/my_app_name/application.rb to the following:
module MyAppName
  class Application < Roda
    route do |r|
      r.on 'admin' do
        r.run Admin::Application.freeze.app
      end

      r.run Main::Application.freeze.app
    end
  end
end
am I doing it right?
Andy Holland
@AMHOL
@georgemillo looks good to me
George Millo
@georgemillo
third mystery: how did I manage to misspell 'routes' above, when I have to deal with that word all day every day as a web developer?
I don't know how to English
Andy Holland
@AMHOL
:laughing: I didn't notice ;)
I haerd taht if you jmulbe up the ltetres in the mdidle of echa wrod in a snetnece poelpe can sitll raed it
MarkT
@paradisaeidae
thanks @cdennl ! Reading it now. I kinda like the reading so far!
Adam Davies
@adz

I’m a bit confused with Dry Struct….

It used to be in drytypes: Dry::Types::Struct now its on its own so change to Dry::Struct, right?

What stupid thing am I doing here:

class CreateClientForm < Dry::Struct
  module Types
    include Dry::Types.module
  end

  attribute :name, Types::Form::String
end

which appears to not find “String” constant…

specs in dry struct do:

attribute :name, ‘coercible.string’
is this how I should change things?

Maybe this should be Types::Coercible::String ??
that seems to work… hmmm

I just assumed all ‘form’ values here so use that, but perhaps I should read more closely descriptions of each….

Adam Davies
@adz

…in
http://dry-rb.org/gems/dry-validation/comparison-with-activemodel/
trying to understand

    option :account
    def unique?(attr_name, value)

and how it’s params line up with

schema.with(object: user_account).call(input)

1) is that ‘object’ key special? I thought it would be ‘account’
2) i guess that the ‘unique?’ method gets curried, so ‘value’ comes in…
but a little down”
required(:email).filled(scoped_unique?: :email, scope?: { active: true })
seems to pass in as a key “scope?:” but receive it as a positional arg… ok i guess… if i have it straight

Adam Davies
@adz

Just to report back… seems like that doc is wrong. Probably was specialised for ‘account’ then generalised to ‘object’ but not fully.

I think it should be something like:

      option :record

      def unique?(attr_name, value)
        record.class
        .where.not(id: record.id)
        .where(attr_name => value)
        .empty?
      end
Adam Davies
@adz
Here’s a PR to correct ^ dry-rb/dry-rb.org#138
Tim Riley
@timriley
@adz we don’t have form types for strings in dry-types since forms will always submit strings anyway. No need for coercion. You could always just use Types::Strict::String in such a case.
@adz Also, the typical setup (so far at least) for handling form submissions is to run the form params through a dry-validation schema first anyway, which’ll handle any form coercions and give you properly structured and typed Ruby values out the other end. This means that you can then avoid having to use form types in your structs.
Adam Davies
@adz
Yeah I see. Actually did that with dry and ROM project. Was following this write-up to get started in a Rails app
It uses dry struct for form object with dry validation for save call
Tim Riley
@timriley
oh that’s interesting
George Millo
@georgemillo
is there a way to use a dry struct as a type in another dry struct?
Tim Riley
@timriley
@georgemillo yep!
module Types
  include Dry::Types.module
end

class Address < Dry::Struct
  attribute :suburb, Types::Strict::String
end

class Customer < Dry::Struct
  attribute :name, Types::Strict::String
  attribute :address, Address
end

Customer.new(name: "George", address: {suburb: "Test Town”})
# => #<Customer name="George" address=#<Address suburb="Test Town">>
Rafael
@lastk
Tim Riley
@timriley
@lastk I think you might be asking in the wrong room. I think you’re after trailblazer/chat
Rafael
@lastk
ops
yes, you're right, sorry :P
Adam Davies
@adz

Following on from experimenting with dry-validations…
How would you verify uniqueness when scoped to another record?

Say “account” has many “users”, and I want users.name to be unqiue within an account….

Tim Riley
@timriley
@adz I’d write a predicate like unique_within_account?(account_id, user_name)
Adam Davies
@adz
Thanks… how would that look when called? I’m a little confused about that