Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Tim Riley
@timriley
@jdickey no worries!
Pablo Crivella
@pablocrivella
Does anyone has some tips/best practices for using dry-transactions/operations? Like is it better to always use keywargs, or when to use step_args and when not to. Naming conventions, etc. Any feedback is welcome :sweat_smile:
Eliav Lavi
@eliav-lavi

Hello, I wanted to try out dry-web-roda but encountered problems quite early in the process. I read the docs a few times but could not figure it out. Could anybody assist?
Basically, I created a new project with dry-web-roda new dwr_test. Then, within the directory, I ran rake db:create. Then I tried rackupand then got this:

dwr_test rackup
/Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/view/controller.rb:13:in `block in <class:Controller>': undefined method `context=' for #<#<Class:0x00007f82150fe198>:0x00007f82150e5e18> (NoMethodError)
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-configurable-0.7.0/lib/dry/configurable.rb:70:in `configure'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/view/controller.rb:11:in `<class:Controller>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/view/controller.rb:10:in `<module:View>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/view/controller.rb:9:in `<module:Main>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/view/controller.rb:8:in `<module:DwrTest>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/view/controller.rb:7:in `<top (required)>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/views/welcome.rb:1:in `require'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/lib/dwr_test/main/views/welcome.rb:1:in `<top (required)>'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/container.rb:541:in `require'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/container.rb:541:in `require_component'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/auto_registrar.rb:37:in `block in call'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/auto_registrar.rb:34:in `each'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/auto_registrar.rb:34:in `call'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/auto_registrar.rb:27:in `block in finalize!'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/auto_registrar.rb:27:in `each'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/auto_registrar.rb:27:in `finalize!'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/dry-system-0.9.2/lib/dry/system/container.rb:300:in `finalize!'
    from /Users/eliavlavi/git_projects/roda/dwr_test/apps/main/system/boot.rb:3:in `<top (required)>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/system/boot.rb:15:in `require'
    from /Users/eliavlavi/git_projects/roda/dwr_test/system/boot.rb:15:in `block in <top (required)>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/system/boot.rb:14:in `each'
    from /Users/eliavlavi/git_projects/roda/dwr_test/system/boot.rb:14:in `<top (required)>'
    from /Users/eliavlavi/git_projects/roda/dwr_test/config.ru:1:in `require_relative'
    from /Users/eliavlavi/git_projects/roda/dwr_test/config.ru:1:in `block in <main>'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/rack-2.0.6/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'
    from /Users/eliavlavi/git_projects/roda/dwr_test/config.ru:in `new'
    from /Users/eliavlavi/git_projects/roda/dwr_test/config.ru:in `<main>'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/rack-2.0.6/lib/rack/builder.rb:49:in `eval'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/rack-2.0.6/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/eliavlavi/.rvm/gems/ruby-2.4.2/gems/rack-2.0.6/lib/rack/builder.rb:40:in

I had to truncate the end of it, gitter was trimming me. Any idea what's wrong?
Thanks a lot 🙏

Vasily Kolesnikov
@v-kolesnikov
Hi @eliav-lavi :wave:
It should not be so hard to fix.
Do you have a repository with this code?
Eliav Lavi
@eliav-lavi
@v-kolesnikov Hello :wave:, I do not but I can push it to github, honestly it's very "raw" - happens just after creating a new project. I think there is some mismatch between dry-configurable to dry-view in some sense, but not sure (the config object yielded to configure doesn't have a context attribute). If it's easier I'll push it to github, would that be preferable?
Thank you!
Vasily Kolesnikov
@v-kolesnikov
I need to know which version of dry-w you used to be more precise.
Just push it and share the link.
Eliav Lavi
@eliav-lavi
from gem list, these are the dry gems:
dry-auto_inject (0.6.0, 0.4.6, 0.4.4)
dry-configurable (0.7.0)
dry-container (0.6.0)
dry-core (0.4.7, 0.4.4, 0.3.4)
dry-equalizer (0.2.1, 0.2.0)
dry-events (0.1.0)
dry-inflector (0.1.2)
dry-initializer (2.5.0, 2.3.0, 1.4.1)
dry-logic (0.4.2)
dry-matcher (0.7.0, 0.6.0)
dry-monads (1.0.1, 1.0.0, 0.4.0, 0.3.1)
dry-monitor (0.1.2, 0.0.3)
dry-struct (0.5.1, 0.5.0, 0.4.0, 0.3.1)
dry-system (0.10.1, 0.9.2, 0.8.1)
dry-transaction (0.13.0, 0.10.2)
dry-types (0.13.2, 0.12.3, 0.12.1, 0.11.1)
dry-validation (0.12.2, 0.11.1, 0.11.0)
dry-view (0.5.4, 0.4.0)
dry-web (0.8.0, 0.7.1)
dry-web-roda (0.11.0, 0.9.0)
OK, on it, thanks!
Vasily Kolesnikov
@v-kolesnikov
Two version of dry-w :smile:
Eliav Lavi
@eliav-lavi
😩 I just noticed that!
it's weird, I barely touched the Gemfile, just added ruby '2.5.3' and gem "shotgun"...
Vasily Kolesnikov
@v-kolesnikov
and?
Eliav Lavi
@eliav-lavi
will be on gh in a minute or two :clock1:
Eliav Lavi
@eliav-lavi
Sorry, some authentication issue with github... on it, will let you know once its there. Thank you again
Eliav Lavi
@eliav-lavi
OK, there it is https://github.com/eliav-lavi/dwr_test @v-kolesnikov
Vasily Kolesnikov
@v-kolesnikov
:eyes:
Eliav Lavi
@eliav-lavi
Appreciated
Vasily Kolesnikov
@v-kolesnikov
The reason is some breaking changes in dry-view between 0.4.x and 0.5.x versions. I just see that dry-w was tested with dry-view 0.4.x only.
Eliav Lavi
@eliav-lavi
Oh. I assumed something like that. I'll try downgrading in the gemfile
Vasily Kolesnikov
@v-kolesnikov
I have already tried. It works.
Eliav Lavi
@eliav-lavi
Indeed, works
Thank you so much!
So the issue is with dry-web then... should this be raised on the discussion forum?
Vasily Kolesnikov
@v-kolesnikov
I really like dry-w concept, but I use it not in a direct way. I have some projects (open and private as well) which built on top of dry-web-roda and at the end, in my latest project I don't use dry-web-roda as a dependency, instead I use its template. I have system and lib dirs, use dry-system to manage components, use roda as a router and so on. But just without dry-w as a dependency. I doesn't mean I have something against dry-w, just share my experience.
@eliav-lavi Seems like you should use the following: config.default_context = Container["view.context"]
In dry-view 0.5.x
Vasily Kolesnikov
@v-kolesnikov
Eliav Lavi
@eliav-lavi
@v-kolesnikov changing context to default_context is something I already tried after sniffing around a bit in debug mode and just trying things out, but it leads to another error:
NoMethodError: undefined method `for_rendering' for #<DwrTest::Main::View::Context:0x00007fd53fc59f38>
    /Users/eliavlavi/.rvm/gems/ruby-2.5.3/gems/dry-view-0.5.4/lib/dry/view/rendering.rb:23:in `initialize'
    /Users/eliavlavi/.rvm/gems/ruby-2.5.3/gems/dry-view-0.5.4/lib/dry/view/rendering.rb:7:in `new'
    /Users/eliavlavi/.rvm/gems/ruby-2.5.3/gems/dry-view-0.5.4/lib/dry/view/rendering.rb:7:in `prepare'
    ...
127.0.0.1 - - [18/Jan/2019:10:47:25 +0200] "GET / HTTP/1.1" 500 151990 0.0265
Tim Riley
@timriley
Are you using dry-view master? All of this stuff isn’t released yet.
Nor is it documented yet.
Context classes now need to inherit from Dry::View::Context
Eliav Lavi
@eliav-lavi
@timriley I guess so? I ran gem install dry-web-roda, then dry-web-roda new dwr_test, then cd dwr_test and then bundle install. What currently works for me is forcing dry-view to be below 5.x, in the gemfile: gem "dry-view", "~> 0.4", "< 0.5"
the "< 0.5" is my addition, without it it didn't work
Tim Riley
@timriley
Ack, it seems like a bunch of stuff made it into 0.5.4 that shouldn’t be there
I’m going to yank it now
Yanked.
0.5.3 should work for you.
Sorry about that, @eliav-lavi
You’ll want to gem uninstall dry-view -v 0.5.4 and then re-bundle
Eliav Lavi
@eliav-lavi
No worries @timriley! I I guess that's not very trivial to coordinate seamless compatibility like that :) Really appreciate the work done here.
Piotr Solnica
@solnic
it's a bigger challenge when gems are in beta, after things settle it becomes much simpler
Piotr Solnica
@solnic
@v-kolesnikov re ditching dry-web-roda, it doesn't surprise me because this gem is really just a tiny integration between dry-system and roda, it can help people get up and running quickly but there's very little it actually provides (which is a wonderful thing, btw). given that we're now focusing more on hanami 2.0/3.0 effort, it's possible we'll discontinue dry-web* gems unless somebody would like to take over them
Eliav Lavi
@eliav-lavi
@solnic If I may intervene, one of my main problems with Hanami is that it creates an instance of an action per request. FooAction.new.call(args) - even if I can override the initialize method, as they describe, this is not how I want to do it, I want to have a single instance of those classes and just pass data through them.
What's your view of that aspect, if I may?
Jeff Dickey
@jdickey
@solnic :+1: That makes sense to me too. I remember poking at dry-web-roda when it was first published, and then going back to my own Rube Goldberg integration because I understood that and didn't see where d-w-r was trying to go, going forward. Tying up Dry + Hanami + ROM in the way that's been described over the last few months makes much more sense to me and my team, and we're excited to see where that goes
Tim Riley
@timriley
@eliav-lavi I’m not 100% sure how hanami actions work in 1.x, but in 2.0, whenever it comes out, what you describe will be possible
I think 1.x actions mutate their state, so it would make sense to get a new object each time