Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Greg
@greggilbert
:/
Sean Collins
@cllns
upgrading isn't possible?
Greg
@greggilbert
not at this moment?
Kai Kuchenbecker
@kaikuchn
@RemiBa what version of Hanami-Model are we talking about?
Corey Jack Wilson
@coreyjackwilson
Silly question, is Hanami support on Windows? or are there missing packages?
James McCann
@jamesmccann
Hi all, I'm having an issue with hanami/router being mounted at a path, here's a test script
require 'hanami/setup'

class TestApp < Hanami::Application
  configure do
    routes do
      get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }, as: :hello
    end
  end
end

Hanami.configure do
  mount TestApp, at: '/app'
end

run Hanami.app

puts TestApp.routes.path(:hello)   # =>  /app/hello
puts TestApp.routes.recognize('/hello').action  # =>  proc
puts TestApp.routes.recognize('/app/hello').action # =>  nil
I'm not sure if this is an issue or just the way I'm trying to use/abuse the router. Calling TestApp.routes.path returns a path prefixed with the path where the app has been mounted, but calling TestApp.routes.recognize with the same path doesn't recognize the route. Calling recognize without the mount path works fine.
Hence I can't do path = TestApp.routes.path(:action) and then action = TestApp.routes.recognize(path)
Sean Collins
@cllns
I'd think that TestApp.routes wouldn't know anything about /app, but Hanami would
James McCann
@jamesmccann
@cllns yes, it makes sense for Hanami to need to prefix the path/url before it hits the browser, but should TestApp.routes.path be including the prefix?
m.b.
@mbajur
guys! Has anyone had any troubles with displaying hanami logs when runned inside a docker container? When i'm doing so (with a default setup of hanami), all the logs i can see in the docker-compose output are about Webrick started and the exceptions. For some reason, access logs nor sql queries are not displayed in there.
Kai Kuchenbecker
@kaikuchn
@mbajur Hey, please use gender-agnostic greetings, it's not just guys in here ;) Regarding your question: Docker logs just gathers the stdout, however by default most logs go into files which you can find in the log/ folder.
Wait, sorry that's not true. Default is STDOUT. Maybe you configured it to stream to files or configured a different logging level?
Qqwy / Marten
@Qqwy

@kaikuchn Does 'views escape automatically the output of their methods' mean that something like

div do
  User.get_name_that_might_be_unsafe(user_id)
end

is escaped or not?

And what about

form_for :book, routes.books_path, class: 'form-horizontal' do
  text_field :title, class: User.get_name_that_might_be_unsafe(user_id)
end

?

Gabriel Gizotti
@gizotti
@jodosha would you say Interactors and Trailblazer::Operation would be equivalent? Not on how they work internally but why they would be used
I am writing a talk on Interactor and am trying to find similar libraries libraries
Qqwy / Marten
@Qqwy
@gizotti For its equivalent in functional programming, you might take a look at Elixir's (or more appropriately, Ecto, the most prominent ORM built in Elixir) Changeset functionality: https://hexdocs.pm/ecto/Ecto.Changeset.html#content
And I do agree that it seems to overlap with what Trailblazer::Operation does as well.
Gabriel Gizotti
@gizotti
@Qqwy would changeset be used for Use Cases though? It looks more likely to be used to process data before it is persisted in the DB
Qqwy / Marten
@Qqwy
@gizotti You are correct.
There is also a slightly higher-level abstraction called Ecto.Multi, which works across models to build steps of validations, plain functions and DB-requests/responses. ( https://hexdocs.pm/ecto/Ecto.Multi.html#content).
This second one is more often used in complex use cases, i.e. as part of a public API context/domain function. It has as advantage that it can be inspected and tested without actually using a database.
because you construct a list of steps before executing it.
which I think (please correct/educate me) is similar to what Interactor and Trailblazer::Operation do.
Gabriel Gizotti
@gizotti
@Qqwy I am not that familiar with Elixir, so I can't say if it's too similar to Interactors.
The idea of Interactors is that it receives some input data, it processes this data, doing any operation you need with as many different classes as you need, and it spit back a Result object with the state of the use case, and any data you wish to expose to the caller of the interactor.
So it's not really tied to any particular Entity or Class. You can you whatever makes sense to your use case in there.
Qqwy / Marten
@Qqwy
And the Result is an option type? (either successful with result data, or failure with a list of errors?)
Gabriel Gizotti
@gizotti
exactly that
Qqwy / Marten
@Qqwy
I see! I read through the source just now (the documentation page needs some more information to be understandable at a glance I think)
Gabriel Gizotti
@gizotti
I had to go through the source code the first time as well. :)
But its very simple and I am using it everywhere I can now
Qqwy / Marten
@Qqwy

but what it actually is, is (an OOP-wrapper of) the so-called 'Either Monad'.

Which is not scary! It is nothing more than saying 'I have a pipeline of steps I want to execute one after the other, and somewhere in the middle, it might fail with an error message.

and you first build the pipeline, and then you execute it at a later time
Gabriel Gizotti
@gizotti
I tried reading about Monads before...was too sleepy and gave up lol
I like that it gives me the flexibility to do whatever I want, anyway I want, and gives me a small api to return whatever the caller needs to know
Qqwy / Marten
@Qqwy
Don't worry about it. Understanding Monads is something that can only happen with time and effort. All monad tutorials out there are bad, because they are simply so abstract that they are hard to grasp in general.
But they are the kind of pattern that is so useful that it arises naturally (so you don't have to think about them too much ;-p)
:-)
Yes, it really is a good way to write understandable and maintainable code.
(and with 'it' I mean a pipeline like Hanami::Interactor provides)

Ah, the README of hanami-utils states:

Standardized Service Object with small interface and rich returning result.

:-)
Gabriel Gizotti
@gizotti
So good hey
Qqwy / Marten
@Qqwy
Yes!
Hanami has made some wonderful choices
I am really glad I found it; I've been using Rails professionally for a couple of years now but it really breaks all the rules and results in horrible messes of code.
Gabriel Gizotti
@gizotti
Also I totally recommend Deckset for putting together presentations in Markdown
Qqwy / Marten
@Qqwy
Ooh! I'll check it out
Looks wonderful. But as I'm on a Linux machine, I won't be able to use this mac-only piece of software =/