Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • Mar 07 15:59
  • Mar 07 15:59
    htcarr3 starred hanami/hanami
  • Mar 07 13:03
    adam12 review_requested #1098
  • Mar 07 13:03
    adam12 labeled #1098
  • Mar 07 13:03
    adam12 assigned #1098
  • Mar 07 13:03
    adam12 opened #1098
  • Mar 07 13:03
    adam12 milestoned #1098
  • Mar 07 12:08

    adam12 on fix-deprecation-warning-minitest-generated-specs

    Update generated minitest specs… (compare)

  • Mar 07 11:30
    adam12 assigned #1020
  • Mar 07 11:26
    adam12 unlabeled #1077
  • Mar 07 11:26
    adam12 closed #1077
  • Mar 07 11:26
    adam12 commented #1077
  • Mar 07 02:52
    librity starred hanami/hanami
  • Mar 06 20:30
    kimious starred hanami/hanami
  • Mar 06 12:03
  • Mar 06 07:16
    depfu[bot] labeled #623
  • Mar 06 07:16
    depfu[bot] opened #623
  • Mar 06 07:16

    depfu[bot] on update

    Update rom-sql to version 3.3.3 (compare)

  • Mar 05 16:44
    wenderjean commented #595
  • Mar 05 14:26
    zelaznogydna91 starred hanami/hanami
Brett Dudo
to clarify, I'd like to do api + controllers
this example in the api readme is the only thing that touches on it get "/users", to: Actions::V1::Users::Index.new
Brett Dudo
and where should I call Hanami::Controller.load!?
Brett Dudo
tinkering with folder structure
Sebastjan Hribar
@azzz we have a similar use case, where we had to implement touching multiple repos, doing some checks, catching exceptions and so forth. We now have all business logic for this in an interactor. For example, a request comes in through ajax to an action that calls this interactor. Have a look here to see how Hanami implements them. I find interactors to be a great way to organize such code.

Actually the team is working hard on v2

Sure! But why it's like invisible for the others?
30 Jan 2019

Yuriy Tsemashko
@sebastjan-hribar thanks, I didn't find the interactors before.
Brett Dudo
when using "actions" with hanami-api, the self.body= setter doesn't seem to work. This works. Feels like I'm not doing something correctly, though
also, I couldn't get validations to work. is the dot syntax correct, or the block syntax? there's competing docs
Brett Dudo
if anyone finds this... I ended up just keeping things in config.ru, and it's pretty clean with the serializers
kelvin romero
Hello everyone. Any of you happen to use some health check gem for Hanami?
Sebastjan Hribar
I've recently asked about getting the controller for each action. I need to get controller name, like Task. I couldn't find any other way but to pars Web::Controllers::Task::New for example. Is there a better way?
by action you mean route ?
Sebastjan Hribar
I mean I currently deal with what is listed under Action if I run hanami routes: Web::Controllers::Users::Index. In this particular case I'd grab Usersand use singular form and Index.

HI, I noticed a problem during migration execution, basically I've got migration like this:

Hanami::Model.migration do
  change do
    create_table :users do
      primary_key :id

      column :email,              String, null: false
      column :encrypted_password, String
      column :phone_number,       String

      column :created_at, DateTime, null: false
      column :updated_at, DateTime, null: false

When I run it, it shows me following snippet

[hanami] [ERROR] PG::UndefinedTable: ERROR:  relation "schema_migrations" does not exist
LINE 1: SELECT NULL AS "nil" FROM "schema_migrations" LIMIT 1
                                  ^: SELECT NULL AS "nil" FROM "schema_migrations" LIMIT 1
[hanami] [INFO] (0.042149s) CREATE TABLE "schema_migrations" ("filename" text PRIMARY KEY)
[hanami] [ERROR] PG::UndefinedTable: ERROR:  relation "schema_info" does not exist
LINE 1: SELECT NULL AS "nil" FROM "schema_info" LIMIT 1
                                  ^: SELECT NULL AS "nil" FROM "schema_info" LIMIT 1

But, when I add null: true to encrypted_password and phone_number everything works smoothly. Both in hanami guide and in rom-sql I see this is an optional attribute. Anyone has idea what can cause this issue?

The 2 problem seem pretty unrelated, so I'd guess there is a typo somewhere
do you have other migration files ?
are you sure there isn't an invisble char (like unbreakble space) that messes up with the migration content ?
Kai Kuchenbecker
There isn't any actual problem in the provided log output
What's happening is that when migrations run the migrator first checks whether the required tables schema_migrations and schema_info exist, if they don't they are created.
Sadly this step is rather verbose and outputs this non-error as if it were an error... but it's how the underlying gem handles it and we cannot do much about it.

Hi, thank you @inouire_twitter and @kaikuchn for responding me. I'll verify if there is no invisible char when in the evening. Also, this is the only migration I have.

About the errors and checks - what I see is in related database schema_migrartions table is being created but no schema_info is present. Also, running hanami db prepare once again, on already migrated database, the output of execution remains the same.

Noman Ur Rehman
Are there documented problems with Hanami inside a container?
I remember everything working correctly long ago when I was using it on my local machine
But with Docker, I seem to be having a lot of boot issues
Everytime, it is something new :(
If anyone is curious about my problem I had - I should write at first what command I have used :) I used hanami db prepare (as guides described) instead of hanami db migrate.Basically, this command is for setup, but raises above errors. Running hanami db migrate did the job.
Sebastian Schürmann
hello. Just a short question: is there a hanami version of active_admin?
Sven Schwyn
@sebsonjura I've done quite some with work with AA and Rails, so although not 100% sure, I doubt there's a fork for Hanami. The coupling with Rails goes pretty deep. (Also, I wouldn't chose AA anymore for backends, we got a head start in the beginning, but ran into tons of trouble later on due to hardcoded opinions and limitations – however, your mileage may vary.)

Hello, I'm using hanami-api and hanami-controller (action) as standalone gems. Now I observe an issue and hope somebody can help me. I have a GraphQL-controller, which should use the Authorization-Header to authenticate. So in the controller I get the header-value as described in the docs:

bearer_token = request.env['HTTP_AUTHORIZATION']

this works for the first request after application-startup. If I change the header at the client application (i.e. to an invalid token). The controller gets always the token from the first request. So the header get cached. If I investigate the whole rack.env,


I get something like this:

  "rack.version"              => [
  "rack.errors"               => #<Rack::Lint::ErrorWrapper:0x000055bd2bc60b68 @error=#<IO:<STDERR>>>,
  "rack.multithread"          => true,
  "rack.multiprocess"         => false,
  "rack.run_once"             => false,
  "SCRIPT_NAME"               => "",
  "QUERY_STRING"              => "query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D",
  "SERVER_PROTOCOL"           => "HTTP/1.1",
  "SERVER_SOFTWARE"           => "puma 5.0.4 Spoony Bard",
  "GATEWAY_INTERFACE"         => "CGI/1.2",
  "REQUEST_METHOD"            => "GET",
  "REQUEST_PATH"              => "/graphql",
  "REQUEST_URI"               => "/graphql?query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D",
  "HTTP_VERSION"              => "HTTP/1.1",
  "HTTP_HOST"                 => "localhost:9292",
  "HTTP_USER_AGENT"           => "Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0",
  "HTTP_ACCEPT"               => "application/json, text/plain, */*",
  "HTTP_ACCEPT_LANGUAGE"      => "en-US,en;q=0.5",
  "HTTP_ACCEPT_ENCODING"      => "gzip, deflate",
  "HTTP_AUTHORIZATION"        => "Bearer old_token",
  "HTTP_CONNECTION"           => "keep-alive",
  "HTTP_COOKIE"               => "MicrosoftApplicationsTelemetryDeviceId=cd5cc910-fc4f-436e-8ea7-f93b17fd7093; MicrosoftApplicationsTelemetryFirstLaunchTime=2020-01-08T14:59:29.306Z",
  "puma.request_body_wait"    => 0,
  "SERVER_NAME"               => "localhost",
  "SERVER_PORT"               => "9292",
  "PATH_INFO"                 => "/graphql",
  "REMOTE_ADDR"               => "",
  "puma.socket"               => #<TCPSocket:(closed)>,
  "rack.hijack?"              => true,
  "rack.hijack"               => #<Proc:0x000055bd2bc60ff0 /home/armwur/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/lint.rb:567>,
  "rack.input"                => #<Rack::Lint::InputWrapper:0x000055bd2bc60b90 @input=#<Puma::NullIO:0x000055bd2c024a88>>,
  "rack.url_scheme"           => "http",
  "rack.after_reply"          => [],
@_env={"rack.version"=>[1, 6], "rack.errors"=>#<Rack::Lint::ErrorWrapper:0x000055bd2ce5e158 @error=#<IO:<STDERR>>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "HTTP_AUTHORIZATION"=>"Bearer new_token", "QUERY_STRING"=>"query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 5.0.4 Spoony Bard", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/graphql", "REQUEST_URI"=>"/graphql?query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_HOST"=>"localhost:9292", "HTTP_USER_AGENT"=>"Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0", "HTTP_ACCEPT"=>"application/json, text/plain, */*", "HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.5", "HTTP_ACCEPT_ENCODING"=>"gzip, deflate", "HTTP_CONNECTION"=>"keep-alive
So the @_env of rack contains the new token. What I'm doing wrong?
Could following hint at the guides be an explanation?
 Instantiating a request for each incoming HTTP request can lead to minor performance degradation. As an alternative, please consider getting the same information from private action methods like accept? or from the raw Rack environment params.env.
It seems so, because params.env['HTTP_AUTHORIZATION']returns everytime the current Auth-Header.
Hello, I'm a web app beginner and have just started learning ruby and hanami. I am trying to follow the official guide here https://guides.hanamirb.org/introduction/getting-started/ but I encountered some problems when I tried to run the command "bundle exec hanami db prepare". It mentioned that 'The system cannot find the file specified'.
Also when I tried running "bundle exec hanami console", it returns this message:
[ROM::Relation[Books]] 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 (schema parsing returned no columns, table "books" probably doesn't exist)
Would really appreciate it if you could give me some advice, thanks!
Hello, how is it possible to add custom-header to hanami mailer?
Kai Kuchenbecker
@rafeang Hi and welcome to the community. I see that you are using Windows as your operating system. I have no clue about the current state of windows support in Ruby itself nor which gems work and which do not work. I suspect you will have a harder time using windows that you would have using Linux or OSX.
However, I believe you may be able to use Windows Subsystem for Linux (WSL) to have a nicer experience.. I'm only guessing since I don't use Windows at all and have no idea about the specifics of WSL, I just heard about it somewhere..
Kai Kuchenbecker
Anyway regarding your specific error: I see that you're using SQLite and it tries to load the structure file. This file usually only exists after you have run migrations successfully at least once.
So maybe try to execute bundle exec hanami db create and bundle exec hanami db migrate manually instead of hanami db prepare (which should just do those two steps for you).
Kai Kuchenbecker
Another thing you may check is your configuration. Are you maybe using SQLite in Memory mode? If I recall correctly people struggle with that.. but I'm unsure about it. Maybe it's broken?
Anyway, quickfix here would be to not use the memory mode.
Hello, do we know when hanami-model v1.3.3 is released? It's not possible to use Hanami with ruby 2.7 because of this issue hanami/model#570
@Neinea_gitlab: Luca was asked to cut one around Dec 2 but I'm not sure he's had the time.

Hi, I have a question. I like to disable hanami/model's sql log on production environment.
Looking at this PR: hanami/model#368, seems it is not possible to disable sql log. Correct?

And I have found a similar question on the chat: https://gitter.im/hanami/chat/archives/2019/05/22?at=5ce506d76366992a94ff0162, but cloud not find any helpful hacks.

1 reply

@Neinea_gitlab: Luca was asked to cut one around Dec 2 but I'm not sure he's had the time.

Ok ty for answer:)