Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 24 07:14
    wicky-info starred hanami/model
  • Oct 23 09:35

    depfu[bot] on update

    (compare)

  • Oct 23 09:35
    depfu[bot] closed #651
  • Oct 23 09:35
    depfu[bot] commented #651
  • Oct 23 09:35
    depfu[bot] labeled #652
  • Oct 23 09:35
    depfu[bot] opened #652
  • Oct 23 08:31

    depfu[bot] on update

    Update rubocop to version 1.22.2 (compare)

  • Oct 23 08:26
    sswander commented #645
  • Oct 23 08:26
    sswander commented #645
  • Oct 23 08:21

    depfu[bot] on update

    (compare)

  • Oct 23 08:21
    depfu[bot] closed #192
  • Oct 23 08:21
    depfu[bot] commented #192
  • Oct 23 08:21
    depfu[bot] labeled #193
  • Oct 23 08:21
    depfu[bot] opened #193
  • Oct 23 07:19

    depfu[bot] on update

    Update rubocop to version 1.22.2 (compare)

  • Oct 22 17:06
    lddr99 starred hanami/hanami
  • Oct 22 13:42
    rishabg starred hanami/hanami
  • Oct 22 10:50
    mrsnapchad starred hanami/hanami
  • Oct 22 00:21
    hartca starred hanami/hanami
  • Oct 18 12:11
    timriley commented #1123
Aleksander Smywiński-Pohl
@apohllo
Have you tried looking into SQL log?
btw you say you don't get the result
is there an error or the column is missing?
Sebastjan Hribar
@sebastjan-hribar
@apohllo Here is a gist of server log. Note that similarity is appended in line 21 and 33, whereas it is not in the query result for no aggregation.
@apohllo Off-topic: great avatar :)
Armin
@wuarmin
Good morning! Where is the right place to open a Sequel-DB-Connection and store it in a constant in hanami 1.3? In config/environment.rb? The puma webserver uses 5 workers and preloads the app.
Armin
@wuarmin
I have the sequel connect in config/environment.rb but get Sequel::DatabaseDisconnectError: PG::UnableToSend: SSL SYSCALL error: EOF detected-errors after some time, even though I call disconnect of the db in puma's on_worker_boot-hook.
Armin
@wuarmin
Do I have to call disconnect in before_fork?
Árni Gunnarsson
@arni1981_gitlab
Armin
@wuarmin
@arni1981_gitlab great! Thank you. There are so much different assumptions on the web regarding this topic.
Armin
@wuarmin
@arni1981_gitlab I still get the error: Sequel::DatabaseDisconnectError: PG::UnableToSend: SSL SYSCALL error: EOF detected after some time.
Armin
@wuarmin
# config/environment.rb
# ...
DWH = Sequel.connect(ENV['DWH'], :loggers => [Logger.new($stdout)])
#...
# config/puma.rb
require_relative './environment'
workers 5

threads_count = 1
threads threads_count, threads_count

daemonize true
stdout_redirect '/home/user/app/shared/log/puma.stdout.log', '/home/user/app/shared/log/puma.stderr.log', true
pidfile "/home/user/app/shared/pids/puma.pid"

preload_app!

rackup      DefaultRackup
port        2300
environment 'production'

before_fork do
  DWH.disconnect
end

on_worker_boot do
  Hanami.boot
end
Armin
@wuarmin
For the sake of completeness: here's my conclusion about my DatabaseDisconnectError-issue https://stackoverflow.com/questions/66443278/ocurrence-of-sequeldatabasedisconnecterror-at-puma-worker-even-though-the-db/66452766#66452766
Somebody still possibly has a solution trial...
Sebastjan Hribar
@sebastjan-hribar
RE select_append from a few posts up. I couldn't get it to work, i.e. to append to the Segment record. My best guess is the limitation of mapping to the entity. So for now I have a rather ugly workaround where I still do aggregate but overwrite the translation_recordsarray later on. I'll wait for higher versions of Hanami model to refactor this.
Edouard
@inouire_twitter
Thanks @wuarmin I've got some similar problems recently, I will have a look at that
Sebastjan Hribar
@sebastjan-hribar
Hi, is it possible to construct a repository query with optional arguments?
Thomas Carr
@nilclassy
Hey Hanami community, I'm a (frustrated) Rails developer who is really excited about whats going on with Hanami!
Edouard
@inouire_twitter
Welcome Thomas, hope you'll find what you need here
Edouard
@inouire_twitter
What's frustrating you with Rails ?
Sebastjan Hribar
@sebastjan-hribar

Any idea why this raw sql query works

  def find_by_pattern_match_1(search_text)
    segments.read("SELECT * FROM segments WHERE content ILIKE '%#{search_text}%'")
  end

and this one doesn't?

  def find_by_pattern_match(search_text)
    segments
      .where { content.ilike("%?%", search_text) }
  end

The second one doesn't return anything, not even an error. However, they should both return the same result.

Just tried this .where { content.ilike("%#{search_text}%") }and it works.
Does the second one above work for anyone or are the docs outdated?
Armin
@wuarmin
@sebastjan-hribar check the logged SQL of your second query.
Sebastjan Hribar
@sebastjan-hribar
@wuarmin Do you mean the console output? I'm still in the testing stage and I've just checked, all my pg logs are set to stderr.
Sebastjan Hribar
@sebastjan-hribar

Hi again, I have a question regarding the optional params. As per guides I have validations setup like this:

params do
  configure do
    config.messages = :i18n
  end
  required(:term_query).schema do
    required(:source_lang).filled(:int?)
    required(:target_lang).filled(:int?)
    optional(:source_text).filled(:str?)
    optional(:domain).filled(:int?)
  end
end

By filling out/selecting all values except the source_text, the term_query in the params in the controller have these data: {:source_lang=>5, :target_lang=>4, :source_text=>"", :domain=>2}. This is as expected, but params.valid? evaluates to False. Is this the expected result?

Árni Gunnarsson
@arni1981_gitlab
@sebastjan-hribar optional means a key can be omitted, once it is provided however, it goes thru the str? validation
Sebastjan Hribar
@sebastjan-hribar
@arni1981_gitlab Works perfectly :) Thank you!
Árni Gunnarsson
@arni1981_gitlab
@sebastjan-hribar Great, I had exactly the same misunderstanding about how this works just a few days ago.
Sebastjan Hribar
@sebastjan-hribar
@arni1981_gitlab I hadn't thought to look at dry.rb docs :(
Phillip Oertel
@phillipoertel
Hi everyone, I'm trying to figure out how to get the application & and controller which handles a request. I'm using Hanami 1.3.3.
Phillip Oertel
@phillipoertel

Some pseudocode:

def figure_out_handler(rack_env)
  # some calls to Hanami routing in here ...
  "#{application_name}/#{controller_name}#{action_name}"
end

I have several apps (Web and Api, more TBD), mounted at / and /api. If I had just one app, I could call MyApp.routes.recognize(env).action on it, but I with my setup I think I have to go through Hanami.app to resolve things, which I haven't been able to figure out.

I'd like to use this to add an Hanami-instrumentation for the appsignal service and gem.

adam12
@adam12_:matrix.org
[m]
@phillipoertel: You'll probably have to go into the internals. Right before the route is dispatched, presumably it's creating an instance to call. Maybe you could manipulate the Rack env there.
Phillip Oertel
@phillipoertel
@adam12_:matrix.org thanks for your reply. I dug through the internals a little more and came up with a working but ugly and possibly brittle solution:
class PathResolver
  def self.call(path)
    new.call(path)
  end

  def call(path)
    app_configs = Hanami.configuration.mounted.values
    app_configs.map do |app_config|
      return 'root' if path == '/'
      next unless path.start_with?(app_config.path_prefix)

      # returns Api, Web, ...
      app_constant = Module.const_get(app_config.to_s.split('::').first)

      relative_path = path.split(app_config.path_prefix).last

      # returns either nil or something of the form "web_controllers/alive#index"
      app_constant.routes.recognize(relative_path).action
    end.compact.first # return first non-nil value
  end
end
Welcoming any help to make this simpler and more robust ...
Phillip Oertel
@phillipoertel
The above also fails for a route with HTTP PATCH...
Sebastjan Hribar
@sebastjan-hribar
@phillipoertel This is just to let you know I came up with a similar - what looks an ugly - solution to find a particular controller and action in a request. I have a before block that takes an action and finds both like this:
controller = self.class.to_s.split("::")[2]
action = self.class.to_s.split("::")[3]
Árni Gunnarsson
@arni1981_gitlab
What would be the best way to play around with Hanami2, I didn't see anything on the github page or the main hanami page.
adam12
@adam12_:matrix.org
[m]
@arni1981_gitlab: I'd start with Tim's application template, since it's what will be very similar to the what the Hanami 2 CLI will generate. https://github.com/timriley/hanami-2-application-template
Phillip Oertel
@phillipoertel
I asked about a mapping from request path to Hanami app/controller/action recently. Here's what I came up with, maybe it helps someone: https://gist.github.com/phillipoertel/5d99e66d6181b037697cbfce9d0a6d5f
Marcus Pereira
@marcuxyz
thanks
hi, guys! i'm a new user of hanami. I'm creating tests with capybara, How can i to clear database for each test runned?
adam12
@adam12_:matrix.org
[m]
@marcuxyz: I'd look at database_cleaner gem.
Sebastjan Hribar
@sebastjan-hribar
@marcuxyz You could also call the clearmethod on a repo in a before or after block.
Marcus Pereira
@marcuxyz
thanks @adam12_:matrix.org and @sebastjan-hribar for help me
Mark Plaksin
@happymcplaksin_twitter
How do I add an association by ID? Apologies if this is obvious, I can't figure it out :) As an example, let's say I have a book object already and want to add it to an author? IIUC, the example add_book will create the book and doesn't work when passed an ID (or a book object) https://guides.hanamirb.org/associations/has-many/#add-and-remove
Thomas Carr
@nilclassy
Hi I'm working my way through the guides, and am running into an issue on the interactors section. I think there's a missing instruction on updating the routes file for the create action, but even when I add a posts book => books#create to the file my tests still fail with Hanami::Routing::InvalidRouteException:
No route (path) could be generated for :books - please check given arguments
Edouard
@inouire_twitter
Can you be more specific on the syntax you use, and in which file ?
Árni Gunnarsson
@arni1981_gitlab
I'm trying out hanami-controller from the unstable branch, and this gives me the dreaded uninitialized constant Hanami::Controller::Configuration