Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 21 20:23
  • Apr 21 15:57
    senid231 starred hanami/router
  • Apr 21 12:45

    depfu[bot] on update

    (compare)

  • Apr 21 12:45
    depfu[bot] closed #627
  • Apr 21 12:45
    depfu[bot] commented #627
  • Apr 21 12:45
    depfu[bot] labeled #629
  • Apr 21 12:45
    depfu[bot] opened #629
  • Apr 21 11:41

    depfu[bot] on update

    Update rubocop to version 1.13.0 (compare)

  • Apr 21 10:25

    depfu[bot] on update

    (compare)

  • Apr 21 10:25
    depfu[bot] closed #175
  • Apr 21 10:25
    depfu[bot] commented #175
  • Apr 21 10:25
    depfu[bot] labeled #176
  • Apr 21 10:25
    depfu[bot] opened #176
  • Apr 21 09:24

    depfu[bot] on update

    Update rubocop to version 1.13.0 (compare)

  • Apr 20 22:11
    neuroevolutus starred hanami/router
  • Apr 20 14:27
    popeskul starred hanami/hanami
  • Apr 20 13:00

    jodosha on master

    GitHub FUNDING [ci-skip] (compare)

  • Apr 20 10:51
    jodosha synchronize #1096
  • Apr 20 10:51

    jodosha on hanami-2-cli

    Switch to `dry-files` (compare)

  • Apr 20 00:43
    Jay-Dabo starred hanami/router
Edouard
@inouire_twitter
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
@kaikuchn
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.
Robert
@hedselu

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
@nomanurrehman
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 :(
Robert
@hedselu
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
@sebsonjura
hello. Just a short question: is there a hanami version of active_admin?
Sven Schwyn
@svoop
@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.)
Armin
@wuarmin

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,

ap(request.env)

I get something like this:

{
  "rack.version"              => [
    1,
    6
  ],
  "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"               => "127.0.0.1",
  "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?
Armin
@wuarmin
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.
rafeang
@rafeang
image.png
image.png
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!
Armin
@wuarmin
Hello, how is it possible to add custom-header to hanami mailer?
Kai Kuchenbecker
@kaikuchn
@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
@kaikuchn
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
@kaikuchn
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.
Thibault
@Neinea_gitlab
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
adam12_
@adam12_:matrix.org
[m]
@Neinea_gitlab: Luca was asked to cut one around Dec 2 but I'm not sure he's had the time.
S.Tamiya
@ablce9

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
Thibault
@Neinea_gitlab

@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:)

adam12_
@adam12_:matrix.org
[m]
@Neinea_gitlab: I suggested a difference fix. I'm going to try to submit a few PRs this week to resolve them. Maybe we can get a release cut after that.
adam12_
@adam12_:matrix.org
[m]
The fix I suggested would work but doesn't really solve much of Ruby 2.7 or later, because many of the dependencies are still stuck on the old version. Still formulating a plan.
Phong Pham
@pt2pham

Any idea why I would have problems with loading css/js in production on Heroku? Everything works okay locally with RACK_ENV=development bundle exec hanami server. When I use RACK_ENV=production locally, when I turned off the default configurations for production, (e.g.fingerprint, compile,subresource_integrity since I'm not using a CDN yet) it works.

But in actual production, my app doesn't load any of my CSS/JS. I'm using hanami-bootstrap for reference. I also have SERVE_STATIC_ASSETS="true" in my production ENV variables. I checked the logs and I don't see anything failing. Precompiling assets seems to work fine with rake. Any ideas?

Kai Kuchenbecker
@kaikuchn
What I'd check is if you can access the precompiled assets, e.g. visit my.website.com/path/to/asset-with-fingerprint1234.css
If the asset is at that path, then I'd check what path my html pages are referencing and fix that, e.g., maybe you need to use asset-path-helpers?
Daniel Hernández
@heragu

Hi! Is it possible to change handle_exceptions for the application dynamically? I want to test if the exception handling is working as I expect, but the exception handling is deactivated by default.

If I active it, then I don't errors (like typos) while performing other tests.

If I try change it before running the test, the configuration does not react to the change.

# Before hook in my test to check the exception handling
before do 
  Api::Application.configure :test do
    handle_exceptions true # This does not have any effect on the configuration
  end
end
Rafael Soares dos Santos
@rafaels88

hey folks, struggling a bit with preloading associations. How do I preload nested associations? I see that Rom supports doing combine(*nested) but I can't manage to make it work on my hanami Repo

    politicians
      .combine(occupations: [:role])
      .where(id: id)
      .map_to(Politician)
      .one

it tries to find roles instead, I dont understand :roles doesn't exist in ROM::RelationRegistry registry.

Then I tried using join but I simply can't manage to make the where to workout as I dont know how to reference politicians.id. If I do .where(id: id) it doest work as a SQL problem. If I do .where("politicians.id" => id) it doesnt work because Rom/Hanami will use simple quotes for building the query as like WHERE('politicians.id' = 1) and in Postgres that's a problem.

I also tried aggregates(occupations: [:role]) but it falls on the problem as the first. It tries to find roles association and it doesn't exist because an occupation has_one :role.

Anyway, isn't there anyway to preload nested associations on Hanami?

fun fact is that it tries roles instead of role only after I map the association has_one :role on the Occupation repo. Before if tries role (singular) but it can't find anyway
Noah
@94836615
Hi peeps
When I want to run the "hanami" command in my command line this error occurs. B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/definition.rb:33:ininitialize': wrong number of arguments (
given 3, expected 1..2) (ArgumentError)
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/options.rb:17:in new' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/options.rb:17:inwith'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/builder.rb:59:in constructor' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:41:inblock in <module:Types>'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:40:in each' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:40:in<module:Types>'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:4:in <module:Dry>' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:3:in<top (required)>'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types.rb:158:in <top (required)>' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry/validation/input_processor_compiler.rb:1:in<top (required)>'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry/validation/schema/deprecated.rb:1:in <top (requi red)>' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry/validation/schema.rb:14:in<top (required)>'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry/validation.rb:39:in <top (required)>' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry-validation.rb:1:in<top (required)>'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/hanami-validations-1.3.6/lib/hanami/validations.rb:1:in <top (required)>' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/hanami-1.3.3/lib/hanami/frameworks.rb:2:in<top (required)>'
from internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb:85:in require' from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:inrequire'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/h`
Somebody familiar with this error?
adam12
@adam12_:matrix.org
[m]
@94836615: You'll need an older version of Ruby (like Ruby 2.6 or 2.7.2), since Hanami 1 has some warnings (as well as it's dependencies). There's ongoing work with Hanami 2 which will have newer Ruby support, and some work on Hanami 1 to fix these errors.
Noah
@94836615
Roger that thank you :D
Rafael Soares dos Santos
@rafaels88
Anyone for the preloading nested associations? Is that supported by Hanami (as I know it is by rom-db but I can't manage to use it in hanami repo)?
Opan Mustopah
@opan
Hi, currently I am trying to integrate ROM::Factory with Hanami. But it looks like because of some dependencies in Hanami, I only got the oldest version of ROM::Factory. So is it possible to modify the Hanami dependencies, especially in Hanami Model so I can use the latest version of ROM::Factory? My repo can be found here. rom-factory.
3 replies
Rafael Soares dos Santos
@rafaels88

Question about adding association. I'm following this example here https://guides.hanamirb.org/associations/has-many/

  def add_book(author, data)
    assoc(:books, author).add(data)
  end

In my code I have this:

  ...
  associations do
    has_many :politician_occupations
  end
  ...
  def add_occupation(politician, values)
    assoc(:politician_occupations, politician).add(values)
  end

which works, however is performs a query on politician_occupations table with no WHERE right before inserting it. Is that common? Am I missing something?

1 reply
Rafael Soares dos Santos
@rafaels88

ah... I'm feeling a bit dump, I just realised Hanami 1.3.3 is using rom-db 3, this is why I can't use stuff that's on the rom-db docs.

I see it's taking some time for the Hanami 2 to be stable, but now I'm afraid I'll have to rewrite my application a lot in order to migrate from 1.3. Should I wait until starting a fresh application in Hanami?

adam12
@adam12_:matrix.org
[m]

@rafaels88: If you have a reasonably large Hanami codebase already, an alternative might be to use ROM directly and bypass Hanami Model.

If you're starting fresh, you could look at Tim's hanami 2 template. https://github.com/timriley/hanami-2-application-template

1 reply
Both of those solutions use ROM directly. The Hanami::Model -> ROM integration is fairly deep, which is why it hasn't kept pace with ROM updates. There's still ongoing discussion on how to improve that for Hanami 2.
Diego Toral
@diegotoral
Hey guys! Do you have any information about upgrading from hanami 1 to hanami 2? My team is about to start a new big project and I think hanami may be a great fit.
adam12
@adam12_:matrix.org
[m]

@diegotoral: There's not much information yet, but if you want to see an example of what Hanami 2 might look like, check out the Hanami 2 application template from Tim. https://github.com/timriley/hanami-2-application-template

That said, with Hanami, Rails, Sinatra, or anything else, it's good practice to keep as much logic as you can inside lib/. That can help during upgrades / changing frameworks.

Diego Toral
@diegotoral
Thanks @adam12_:matrix.org ! I am looking at that repo.