Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Pat Allan
@pat
Hi folks - just had dependabot open a PR to upgrade a project from alpha 8 to beta 1 🎉 … but, hanami db commands no longer seem to be present. Are they no longer available by default, and is there something I need to do to fix that?
7 replies
Marwan Rabbâa
@waghanza
Hi @jodosha,
Any time to give t the-benchmarker/web-frameworks#5234 ?
3 replies
Sebastjan Hribar
@sebastjan-hribar

Hi, we're still having issues with assets. In my dev environment everything works fine. When I deploy (still on my dev laptop) the app with Docker and using Hanami for serving static assets I get this in the console: Failed to load resource: the server responded with a status of 404 (Not Found) for a lot of assets. However, looking in the public\assetsfolder the different app folders have those assets that are reported missing.

I haven't gotten any further with this. For example, one of the assets not found when running in Docker is this one: http://localhost:8091/assets/sentinel/w3-1ac375ab06574a481efcf0b7fed82b4c.css. However, when I inspect the folder content I find it: /usr/src/app/public/assets/sentinel/w3-1ac375ab06574a481efcf0b7fed82b4c.css. What am I missing?

Sebastjan Hribar
@sebastjan-hribar
Also, I have the docker-compose run the hanami assets precompilecommand so everything is setup as described here.
And this happens for every app in the project. No assets are loaded/found.
Sebastjan Hribar
@sebastjan-hribar
There was an issue with the image. A clean setup solved it.
Sebastjan Hribar
@sebastjan-hribar
An additional note on assets: the favicon icon with fingerprint is not found/loaded for the web app. Even though it is in the required location. This one I can't debug.
Also, we're using webfonts and data tables which require some files to be in their respective folders on the public/assets level. We use command in the docker-compose to copy this with deploy.
Panagiotis Atmatzidis
@atmosx
Hello, I'm considering hanami for a side-project. I'm completely new to the project and it's been a long time since I spent time with rails or sinatra . Should I go with v1.3 or 2.x even though it's beta? Sounds like 2.x brings lots of nice features.
6 replies
Hannes Elvemyr
@ehannes

I just upgraded our Hanami application from alpha8 to beta1. The project was setup using the Hanami 2 template. We now get this error when running rspec:

$ bundle exec rake

An error occurred while loading spec_helper.
Failure/Error: require "hanami/prepare"

NoMethodError:
  undefined method `source_dirs' for #<Hanami::Configuration:0x000000010636bad0 @config=#<Dry::Configurable::Config ... (see full stack trace in thread)
# ./config/app.rb:13:in `<class:App>'
# ./config/app.rb:6:in `<module:MyApp>'
# ./config/app.rb:5:in `<top (required)>'
# ./spec/spec_helper.rb:6:in `require'
# ./spec/spec_helper.rb:6:in `<top (required)>'

Anyone here knowing anything about this source_dirs, has it been renamed? I can't find anything in the Hanami changelog about this. This is my config/app.rb:

# frozen_string_literal: true

require "hanami"

module MyApp
  class App < Hanami::App
    config.sessions = :cookie, {
      key: "my-app.session",
      secret: settings.session_secret,
      expire_after: 60 * 60 * 24 * 365 # 1 year
    }

    config.source_dirs.component_dirs.add "serializers" # <--- crashes here
  end
end

This code worked in Hanami alpha8.

5 replies
R Gibim
@Drowze

Hey guys :wave:
Firstly, thank so much for hanami! I love the project :smile:

I'm currently working with a client (using hanami 1.3) on building a gem that adds a rack middleware which needs the current request path (with path variables names). Sorry if that wasn't clear but for example:
Considering a request to /users/5/posts/1, the rack middleware needs to know that this request was to the path /users/:user_id/:id

That said, I tried to look a bit the documentation for hanami-router and found there's Web.routes.recognize(env) from which I can get the path variables:

route = Web.routes.recognize(env)
route.params # => { :user_id => 5, :id => 1 }
route.path # => '/users/5/posts/1'

..but the path doesn't include the variable names :/ i'm looking for a reliable way to get /users/:user_id/:id. Can anyone help me achieving that?

1 reply
Sebastjan Hribar
@sebastjan-hribar
Hey, joining the 2.0 questions, how difficult will it be to migrate from 1.3 to 2.0? I know it doesn't make much sense asking this, but we're so involved with our project running on 1.3 that I haven't had a chance yet to get into 2.0. Hence, we might have to use 1.3 for a while. Any thoughts on this?
6 replies
R Gibim
@Drowze

Hey guys :wave: another 1.3.x question incoming!

On a fresh project:

# hanami 1.3.x
hanami new hanami_dummy
cd hanami_dummy
hanami generate action web users#index

when visiting /users, I left a binding.irb and checked the rack env via the @_env variable, where I see:

{
  # ...
  "PATH_INFO"=>"",
  "SCRIPT_NAME"=>"/users"
}

I don't understand this! Shouldn't it be the opposite? Aren't they swapped?? According to the rack spec:

SCRIPT_NAME
    The initial portion of the request URL's “path” that corresponds to the application object, so that the application knows its virtual “location”. This may be an empty string, if the application corresponds to the “root” of the server.

PATH_INFO
    The remainder of the request URL's “path”, designating the virtual “location” of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This value may be percent-encoded when originating from a URL.
1 reply
Seb Wilgosz
@swilgosz

About the Hanami 1 -> 2 Upgrade steps: Here is the thread I'd love you all interested to continue on: https://discourse.hanamirb.org/t/hanami-1-3-hanami-2-0/702/2

Hope that helps!

cc: @Drowze @sebastjan-hribar

hsynaccodeing
@hsynaccodeing

Hello!
I am running Hanami 2.0.0.beta.1 and trying to enable JSON parsing as it is shown in Hanami router's readme page.

I am getting the error below as soon as I add the following line in my config.ru file.
require "hanami/middleware/body_parser"

ruby/gems/3.1.0/gems/hanami-router-2.0.0.beta1/lib/hanami/middleware/body_parser/errors.rb:12:in `<class:BodyParser>': uninitialized constant Hanami::Middleware::Error (NameError)

      class BodyParsingError < Hanami::Middleware::Error
                                                 ^^^^^^^
Did you mean?  IOError
               Errno

I am not sure if it is me that is missing something or it is failing to find error.rb class ?
Thanks in advance :)

4 replies
Hannes Elvemyr
@ehannes

Hi!

I've managed to get a working database connection after the beta1 upgrade, but regarding the hanami db create command - what did that command do? I understand that I need to create the database manually now, but then I get the following error:

ERROR:  relation "schema_migrations" does not exist at character 27
STATEMENT:  SELECT NULL AS "nil" FROM "schema_migrations" LIMIT 1
ERROR:  relation "schema_info" does not exist at character 27
STATEMENT:  SELECT NULL AS "nil" FROM "schema_info" LIMIT 1

Did the db create command create those tables, or am I missing something else? Thanks in advance :)

6 replies
Seb Wilgosz
@swilgosz
Hi all, for anyone interested in Hanami 1 -> Hanami 2 Upgrade, I've published a briefing on the changes we did as a first step. I'll publish more detailed articles soon. https://twitter.com/sebwilgosz/status/1564904261590319105
bilel-kedidi
@bilel-kedidi
Hello Everyone. i'm using hanami api and i would like to know, how to make cache with models, ( same for rails : Rails.cache.fetch(key) { Document.where(...) }
1 reply
bilel-kedidi
@bilel-kedidi
Hello guys.
I am working to swith some rails api to hanami api. But i found some issues.
bilel-kedidi
@bilel-kedidi
  1. Is there a template ready to use?. 2. If not how to make hanami api with entities and some actions?
7 replies
Sean Collins
@cllns

Hi Bilel. If you're taking about hanami-api, that will likely be deprecated soon. The reason is that, the full hanami framework will allow you to load only the components you need. And, you can always use hanami-router directly, if you're looking for a minimal API (though, with entities and actions, it seems like you'll want to use the full hanami framework).

If you install gem install hanami --pre then run hanami version to ensure you have v2.0.0.beta2, you can use hanami new to create a new app. FYI though, you'll be on your own for entities for now, and we recommend using ROM 5. Hanami 2.0 won't have a model layer, but Hanami 2.1 will (and will use ROM 6, which isn't out yet)

Seb Wilgosz
@swilgosz
Hi all! Because Hanami 2.0 comes without the Persistence Layer configured, I've prepared a guide how to integrate ROM from scratch for anyone wanting to play with it: https://hanamimastery.com/episodes/28-configure-rom-from-scratch. Hope it helps!
Dima Boyko
@dimaboyko
Hi folks,
i am looking for an advise regarding usage of hanami/view. Would you suggest to use that for API presenters ? Or this is more focused on html template rendering ? In case of a api-only microservice, what recommendations do you have for placing exposure logic ? i am looking at Roar, grape-entity and hanami/view.
Seb Wilgosz
@swilgosz
@dimaboyko i do plan to play with dry-view in my next api application but have not strong opinion on this yet.
Seb Wilgosz
@swilgosz

Hey @/all ,
I had achieved a long-awaited milestone of starting a premium version of Hanami Mastery, to make the first step to sustainability, and ensure this initiative won’t fade away, but rather stay here to promote Hanami long term.

If you’d like to help me a bit, I’d appreciate it if you could fill out this very short feedback form:
https://tally.so/r/n0QRgj

If you’ll hit the checkbox at the top and fill in the twitter handle, I’ll share your feedback with the world :)
Thanks!

Sebastjan Hribar
@sebastjan-hribar
Hey, can someone help me with variable substitution in .env.production?
Sebastjan Hribar
@sebastjan-hribar
Hi, I'm getting this error when deploying with Docker: Errno::EACCES: Permission denied @ rb_sysopen - hanami_log/production.log. I had to create the file under my user with sudo privileges, but Hanami can't write to it either.
hsynaccodeing
@hsynaccodeing
@swilgosz Hi, maybe not the most proper channel to mention this but I have create a small PR for the jay_doubleu_tee gem but haven't gotten any feedback for it for quite sometime now. Just wanted to ping you here, and thanks for the gem! hanamimastery/jay_doubleu_tee#3
2 replies
Simon Thiboutôt
@masterT

Hello, I'm trying Hanami 2 and I can't find a way to configure background jobs using Que. All it needs a Sequel database connection. My first though be using an initializers but it does not seem to exist in Hanami 2. Should I use a provider?
I followed @swilgosz guide to configure the persistence using ROM. What I would like to do is

require 'que'

Que.connection = HomeBar::Container['persistence.db']

This way I can enqueue job like this.

MyJob.enqueue

Jobs are defined like this:

class MyJob < Que::Job
  def run; end
end

Disclaimer I'm new to dry-system and dry-container.
Does someone have a hint for me?

4 replies
Marwan Rabbâa
@waghanza
Hi,
I have /usr/local/bundle/gems/dry-system-0.27.2/lib/dry/system/container.rb:57:in<class:Container>': uninitialized constant Dry::System::Plugins (NameError)` when testing the latest beta in https://github.com/the-benchmarker/web-frameworks/tree/master/ruby/hanami
5 replies
Dima Boyko
@dimaboyko
Hi folks,
i am looking for opinion/advise on parameter parsing with hanami-controller.
Where do you draw the line between using params block within the action and using standalone hanami-validations objects ?or maybe i should go directly with dry-validations ?
Furthermore, what if i need to remap some of the fields from params before processing in inside repository ? (for instance: from http payload i am getting user_id, but would like to pass admin_user_id to repository). where would you place such logic ? should that be within scope of responsibility of validations/coercions or rather separate step within action before calling repo ?
sprock68
@sprock68:matrix.org
[m]
Hello, I'm running the tutorial for 1.3 & getting 'Capybara::ElementNotFound:Unable to find xpath "/html" ' when running 'bundle exec rake' after setting up 'apps/web/templates/home/index.html.erb'. Thanks for any help.
Edouard
@inouire_twitter
Amazing !
In the "How can I try it?" part, shouldn't there be a bundle install between cd bookshelf and bundle exec hanami --help ? or is it specific to each ruby setup ? (rbenv here)
Edouard
@inouire_twitter
-> bonus question: what would be the best doc ressource to poke around with this RC ? thanks !
Seb Wilgosz
@swilgosz
In two weeks should be released official guides, in the meantime we have some draft emerging, https://deploy-preview-114--hanami-guides.netlify.app/v2.0/architecture/slices/
You can check it if you'll keep in mind it's not finished
Edouard
@inouire_twitter
thanks @swilgosz
Alexey Melezhik
@melezhik
Hi guys! I am building CI service with support of many languages, Ruby included . I wonder if hanami needs the one ? I know you already have some setup for GH action Ubuntu . My service can do out if the box arch Linux/ Debian / Ubuntu / Alpine CI tests. I can drop a simple example if you are interested.
Armin
@wuarmin
Hello, does somebody know how I can fix following dep-mismatch?
Bundler could not find compatible versions for gem "dry-core":
  In Gemfile:
    hanami (~> 2.0.0.rc) was resolved to 2.0.0.rc1, which depends on
      dry-core (~> 1.0, < 2)

    rom (~> 5.2) was resolved to 5.2.6, which depends on
      rom-repository (>= 5.2.2, ~> 5.2) was resolved to 5.2.2, which depends on
        dry-core (~> 0.4)

    rom-sql (~> 3.5) was resolved to 3.5.0, which depends on
      dry-core (>= 0.5, ~> 0.5)
Bundler could not find compatible versions for gem "hanami":
  In Gemfile:
    hanami (~> 2.0.0.rc)

    hanami-reloader was resolved to 0.2.1, which depends on
      hanami (~> 1.1)
I want to install rom and rom-sql beside 2.0.0.rc1
Dima Boyko
@dimaboyko
Hi folks, would appreciate a hint with the issue i am having using rc1 https://discourse.hanamirb.org/t/standalone-testing-of-actions-in-rc1/716
Jerzy Sładkowski
@sysadm
Hi guys. Who can help me with the "simple problem" - probably I can't find good documentation. I can't pass through variable, defined on application_controller level to view (partial). Keyword expose doesn't work. So how?
And, btw, do we have any helper to pickup current request with path and params instead of reinvent the wheel based on rack session?
Matthew Weitzel
@mweitzel
This message was deleted
Trevor Turk
@trevorturk_twitter
Hello, I'm looking to configure the "alba" gem to automatically configure itself when in the context of a Hanami app. (In a Rails app: Alba.inflector = :active_support, in a Hanani app: Alba.inflector = :dry.) I believe I found the "correct" way to do this in Rails (https://github.com/okuramasafumi/alba/pull/274/files) but I'm having trouble finding a similar option in Hanami. I'm looking through the latest RC and I see it's easy to manually register a provider within your app, but I'm wondering if there's some way for a non-hanami gem to "inject" itself into a Hanami::App initialization. (Basically I want to have first class support for Rails/Hanami so the user can avoid creating an initializer.)