by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 09:17
    alaptev starred hanami/hanami
  • 07:21
    jodosha labeled #173
  • 07:21
    jodosha milestoned #173
  • 07:21
    jodosha assigned #173
  • 01:57
    hieuk09 commented #365
  • May 30 21:09
    tullur starred hanami/hanami
  • May 30 04:53
    timriley ready_for_review #314
  • May 29 13:10
    timriley edited #314
  • May 29 13:09
    timriley edited #314
  • May 29 13:08
    timriley commented #314
  • May 29 13:07
    timriley ready_for_review #314
  • May 29 13:07
    timriley review_requested #314
  • May 29 13:07
    timriley edited #314
  • May 29 12:53
    timriley edited #314
  • May 29 12:47
    timriley synchronize #314
  • May 29 12:47

    timriley on unstable

    Add full application integratio… (compare)

  • May 29 12:19
    timriley synchronize #314
  • May 29 12:19

    timriley on unstable

    Move existing behavior into Sta… Support setting response body v… Add Hanami::View-compatible ren… (compare)

  • May 29 12:18

    timriley on unstable

    Disable testing of older Rubies (compare)

  • May 29 09:56
    yeongsheng-tan starred hanami/hanami
Kim Pastro
@kimpastro_twitter
i think you can run db prepare with HANAMI_ENV=test
Genésio Valois Coutinho Nt
@GenesioValois
nice!
thank you!!
Kim Pastro
@kimpastro_twitter
no problem
Brett Dudo
@dudo
Hello, folks! I'm working with hanami api, and I just spent the past 2 hours figuring out how to get the body extracted from my POST request. Any thoughts on adding Rack::JSONBodyParser and merging it into params by default?
Edouard
@inouire_twitter
Hi Brett, from what I understood, Hanami API is on Hanami v2, but just in case, here is a piece of doc for the v1 https://guides.hanamirb.org/actions/parameters/#body-parsers
Luca Guidi
@jodosha
@dudo you may want to do this in your config.ru:
require "hanami/middleware/body_parser"

use Hanami::Middleware::BodyParser, :json
Better to document this.
Luca Guidi
@jodosha
Brett Dudo
@dudo
Awesome!! Thank you =)
Jeff Dickey
@jdickey
What have folks been using for end-to-end or integration tests? Selenium is a geriatric pig, and I have yet to see a wrapper for it that makes much of a difference (not that I expected any). Everything else I’m seeign seems to be either JS-specific or deeply tied into Rails. What am I missing?
Brett Dudo
@dudo
Have you tried Capybara?
Tobias Sandelius
@sandelius
@jodosha I saw that you removed resource and resources from the router. You planning on adding those later on or are we better without them?
Brett Dudo
@dudo
Hello folks! Few more questions about Hanami API. It would appear that I'm not initializing the typical config files for hanami. No Hanami.boot or Hanami.config. So I'm curious about config, as I head towards "production" for my api (acting as an api gateway).
Also, curious about cookies - is there a plugin for api?
Brett Dudo
@dudo
Aaaaand I'm wondering about code organization. I see an example in https://github.com/hanami/api#scope that seems to indicate that the normal controllers are available, but I couldn't get them to load for the life of me.
(that last one might be tied to the first question about boot)
Tobias Sandelius
@sandelius

@dudo if you look in the api gemspec you'll see that only the hanami-router is a dependency so the hanami-controller is not there by default.

From the looks of it Api is just a wrapper, with some helpers, for the hanami-router project.

Sebastjan Hribar
@sebastjan-hribar

Hi, I have a problem with an entity without a DB table. I've made a custom schema (https://guides.hanamirb.org/entities/custom-schema/), but I get this response error:

[ROM::Relation[LookupTranslations]] failed to infer schema. Make sure tables exist before ROM container is set up. This may also happen when your migration tasks load ROM container, which is not needed for migrations as only the connection is required (PG::UndefinedTable: ERROR:  relation "lookup_translations" does not exist
LINE 1: ..."."attnum" > 0) AND ("pg_class"."oid" = CAST(CAST('"lookup_t...

Is there something else that needs to be setup?

Arvy Petil
@alnpetil

Is there a way to configure translating the index keys for the #each validation? e.g. required(:domains).each(:str?) if any input passed fails, it returns this {:domains=>{0=>["must be a string"]}}. I'd like to translate 0 for the domains rule as domain instead.

so I get something like domain must be a string instead of 0 must be a string

I've been going over the hanami/validations code and it doesn't seem to support it for each validation. Am I missing something

matheusam
@matheusam
Hello everyone! How are you guys doing? I’ve recently started learning about Hanami, but im really dazed and confused. Maybe rails has rotten my brain away.(just kidding ><)
I just want to build a simple API, witch has only 3 endpoints, i’ve followed along the getting started tutorial, and managed to create the bookshelf app, after some changes i’ve managed to create my API changing some stuff, removing views, changing default response, etc…
This was when I realised the hanami-api gem, but I couldnt create an app as I managed to do with hanami gem.
So my question is, what is the “hanami way” to create an API? I really loved the concept of entities and repositories, and would love to use in my API, but in the gem docs don't make any reference to this concept. I feels like some stuff work in hamani-api and other don't work in hanami, like defining scopes for example.
Is there any way to tell hanami to create an API directly? Without having to change all default setup? Can I have a hanami structure in a hanami-api? Or it will be more like sinatra? One file to rule them all?
I haven't found any guides on how to create specifically an rest API using hanami, have i missed something?
Sorry for this silly question, but i'm really lost.
3 replies
Genésio Valois Coutinho Nt
@GenesioValois
Hi guys!! quick question is it normal to get 200/300ms response time at the development environment?
Edouard
@inouire_twitter
I do have long response time, because of code reloading
Jeff Dickey
@jdickey
@dudo IIUC, Capybara depends (indirectly?) on Selenium (best supported driver?) which rather defeats the purpose. Feel free to correct me or point me towards better docs. Thanks.
@matheusam Repos and entities come with the hanami-model Gem; I won’t get around to it for another few weeks, but you “should” be able to add that to a hanami-api project and, possibly barring some initializer tweaks, have things Just Work. I should be back on in 10-12 hours to help spelunk any more problems but I hope that helps.
2 replies
Brett Dudo
@dudo
postgres db question, if you don't mind, folks
Screen Shot 2020-05-29 at 1.48.53 PM.png
Screen Shot 2020-05-29 at 1.48.31 PM.png
hanami can't seem to connect to the db, but my pod has no problem
I'm using DATABASE_URL=postgresql://
with env PGHOST PGPASSWORD PGPORT PGSSLMODE PGUSER
Brett Dudo
@dudo
DATABASE_URL=postgresql://$(PGUSER):$(PGPASSWORD)@$(PGHOST):$(PGPORT)/$(PGDATABASE)?sslmode=require&ssl=true
gets me further along... but now I'm fighting with SSL
createdb: could not connect to database template1: FATAL: pg_hba.conf rejects connection for host "10.120.0.16", user "doadmin", database "template1", SSL on
ilya-jetruby
@ilya-jetruby
@dudo What is the postgres server? pod, external service, something like RDS?
It tell you that postgres is not configured to accept the connections from the pod's IP. It seems that it accept the local connections only. So you have to configure the postgres properly.
Brett Dudo
@dudo
It’s managed on DO. psql connects fine on the pod, though, so permissions seem fine, no?
ilya-jetruby
@ilya-jetruby
pg_hba.conf rejects connection for host "10.120.0.16"
It's definitely not an application issue but the server's configuration. Or you're connecting to the wrong server )))
Are you sure the DATABASE_URL is correct?
Brett Dudo
@dudo
Positive.
you sure it’s not how the client is instantiating the connection? The fact that psql connects fine feels suspect
its connecting with sslmode require
Kim Pastro
@kimpastro_twitter

hi everyone, i'm struggling in handling exceptions from the template.
the issue:
if I call a method in html.erb file that doesnt exists in view, it throws "NoMethodError"
but, have handle_exceptions true in application.rb within development group
and in actions I put handle_exception Exception => :my_custom_handler

if i manually raise any exceptions in action#call, it works, but when the view thorws the errors the handle do not catch it

it returns the hanami's default 500 page
Sebastjan Hribar
@sebastjan-hribar

Hi, is it possible to get back and use the result of an SQL function? I have setup this to retrieve similar records from the DB based on the pg_trgm similarity function:

def lookup_segments(source_text_for_lookup, sim_score_limit)
    segments.where {similarity(:content, source_text_for_lookup) > sim_score_limit}
end

The :content is an attribute of the segment entity and the source_text_for_lookupis the text the user enters in the form. I get back a set of records which have equal to or greater than match rate compared to the limit, specified by the user.

Here is where I am stuck: I also want to present the user with the calculated similarity (match rate), but the segment itself doesn't have this attribute. Because it is only relevant or it should only exist when the function is called in PG.

Seems as though it is the client - it destructures the url passed to it, so my parameters are lost - ?sslmode=require namely in my case.
Brett Dudo
@dudo
that would explain why psql works - it's just reading the env variables I've set, including PGSSLMODE
Brett Dudo
@dudo
So, turns out, DigitalOcean doesn't support createdb. :facepalm: