Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 16 23:49
    tak1n opened #1164
  • May 16 23:37
    tak1n synchronize #399
  • May 16 23:33
    tak1n synchronize #399
  • May 16 23:32
    tak1n opened #399
  • May 16 23:05
  • May 16 19:24
    tak1n synchronize #376
  • May 16 19:21
    tak1n synchronize #376
  • May 16 19:18
    tak1n commented #376
  • May 16 19:18
    tak1n synchronize #376
  • May 16 17:06
    tak1n opened #377
  • May 16 16:57
    tak1n synchronize #376
  • May 16 16:55
    tak1n synchronize #376
  • May 16 16:40
    tak1n edited #376
  • May 16 16:38
    tak1n synchronize #376
  • May 16 16:10
    tak1n synchronize #376
  • May 16 16:03
    tak1n opened #376
  • May 16 14:12
    tak1n synchronize #375
  • May 16 06:03
    uu-ka starred hanami/hanami
  • May 14 22:55
    Animismo starred hanami/hanami
  • May 14 03:24
    macy212 starred hanami/hanami
Seb Wilgosz
@swilgosz
There is no info yet in the official guides, as guides for 2.0 are in progress, vut will be added soon. Also, here @timriley talked about them a bit here: https://5by5.tv/rubyonrails/353
And finally, I have mentioned slices in the Ruby Rogues podcast episode last week, but this one is yet to be released. You can join my newsletter at hanamimastery.com or follow my twitter to get the info when it's released.
Paweł Synowiec
@synusynu

yup, i read your article. The problem is there is only some brief mention about this topic, i would love to see some examples about what it is and how to use it :)
Are there maybe guides for older version covering this topic?

Thx, i'll check out those talks :)

Sebastjan Hribar
@sebastjan-hribar
Hi all, could someone help me debug an issue with my gem rokku? The tests pass, but when used in production it fails when generating policies. To test just crate a blank 1.3 Hanami app, add rokku to gemfile and run the policy generation command in project root. I'd really appreciate any help. I suspect it's related to the executable, but I'm not sure.
Luca Guidi
@jodosha
Paweł Synowiec
@synusynu

question: i want to add 'log out' link. I have DELETE route for destroying user's session. I want to add it on template, in navbar, but it has to be form (as i need to make DELETE request). But then unit test for Layout fails, because of form helper:

     NoMethodError:
       undefined method `params' for #<Web::Views::ApplicationLayout:0x000055b1bfa7b1a8>

Some ideas? I could change route for GET and use normal link. Or try to disable CSRF protection somehow maybe? Or fix my test somehow :)

Luca Guidi
@jodosha

:mega: Announcement

Folks, as you may have read in the alpha3 announcement, we’re going to release :point_right: monthly alphas :point_left:.

How?

So far the alpha releases were scope bound :chart_with_upwards_trend:.
When the scope was developed, we used to release it.

Now that the ground work is done (thanks Tim :pray: ), we can change the release strategy and make it time bound :stopwatch:.

Once a month, we :shipit: a new alpha, with the improvements that we made since the previous release.
This puts us in a position to release often and build momentum. :fire:

What?

We will focus on the cleanup of the application template. https://github.com/hanami/hanami-2-application-template

The template is a working Hanami 2 app.
By cleaning up it, we can reverse engineer what we need to implement in the framework.

:call_me_hand: If you want to contribute to Hanami, please start from the application template needs, and the work backward to enhance Hanami.

Seb Wilgosz
@swilgosz
Awesome news!
Edouard
@inouire_twitter
Amazing !
Sebastjan Hribar
@sebastjan-hribar
I've fixed issues with CLI for rokku. The new version is now 0.6.2. Don't use lower versions. The authorization checking logic is the same, but building policy files was broken.
Paweł Synowiec
@synusynu
Hello! Is it possible to connect two repositories to the same table?
3 replies
Sebastjan Hribar
@sebastjan-hribar

This is my first part of my yesterday's question. I've removed the gem list:

I'm experiencing a really odd issue. I'm getting TypeError at no implicit conversion of Integer into String for this line: session[:session_start_time] + @validity_time.to_i < Time.now. This started on a development branch where the only change that might impact this is the gemfile or gemfile.lock. On master, session[:session_start_time] is a NilClass and on the development the session[:session_start_time] is a String class. I did delete the gemfile.lock on the development and ran a fresh bundle install. The session[:session_start_time] is set as Time.now.
I've checked Tachiban and irb for the comparison and it runs fine, as well as on the master branch.

Now for the solution:
I've found the culprit. It was hanami 1.5.0. Reverting it back to hanami 1.3.0 solves the problem. Now I don't know, does this qualify for an issue for Hanami or Tachiban?

Andreas Haller
@ahx
This issue in hanami-api about using scope with path parameters feels a bit lonely. hanami/api#29
Maybe you can leave a comment what you think about it? Do you think it's valid?
Some thoughts about choosing ROM over AR. Hope you will find it useful!
warbot
@warbot

Hey, sorry if it's been asked before. 1 day into Hanami
Is there a good hanami 2 app example with project structure?

Found https://github.com/hanami/hanami-2-application-template but it seems it doesn't have all the entities

9 replies
warbot
@warbot

Yo guys, quick question. Does hanami2(rom, sequeel) support psql yet?
When I run:

bundle exec hanami db create_migration apples

I get:

/src/vendor/bundle/ruby/3.0.0/gems/hanami-cli-2.0.0.alpha3/lib/hanami/cli/commands/db/utils/database.rb:32:in `block in []': psql is not a supported db scheme (RuntimeError)
2 replies
warbot
@warbot
Is this the right channel/place to ask hanami2 related questions?
e.g. re PG::ConnectionBad: FATAL
docker-compose run --rm apple_project bundle exec hanami db drop
Creating apple_project_apple_project_run ... done
=> database apple_project_development dropped
❯
❯ brun hanami db create
docker-compose run --rm apple_project bundle exec hanami db create
Creating apple_project_apple_project_run ... done
=> database apple_project_development created
❯ brun hanami db migrate
docker-compose run --rm apple_project bundle exec hanami db migrate
Creating apple_project_apple_project_run ... done
bundler: failed to load command: hanami (/brokerkit/src/vendor/bundle/ruby/3.0.0/bin/hanami)
/brokerkit/src/vendor/bundle/ruby/3.0.0/gems/sequel-5.50.0/lib/sequel/adapters/postgres.rb:210:in `initialize': PG::ConnectionBad: FATAL:  database "apple_project_development" does not exist (Sequel::DatabaseConnectionError)
postmodern
@postmodern:matrix.org
[m]
In the paste hanami devs have suggested asking on their forum which gets more traffic than the matrix channel.
1 reply
Aestimo
@iamaestimo
Hey Hanami Devs, am using the hanami 2 template to create an app and when I try to create migrations hanamin db create_migration create_users I keep getting the error below...what am I missing?
Traceback (most recent call last):
    23: from /home/aes/.rbenv/versions/2.7.2/bin/hanami:23:in `<main>'
    22: from /home/aes/.rbenv/versions/2.7.2/bin/hanami:23:in `load'
    21: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/hanami-cli-2.0.0.alpha3/exe/hanami:10:in `<top (required)>'
    20: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dry-cli-0.7.0/lib/dry/cli.rb:65:in `call'
    19: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dry-cli-0.7.0/lib/dry/cli.rb:116:in `perform_registry'
    18: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/hanami-cli-2.0.0.alpha3/lib/hanami/cli/commands/application.rb:15:in `call'
    17: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/hanami-cli-2.0.0.alpha3/lib/hanami/cli/commands/monolith/db/create_migration.rb:17:in `call'
    16: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/hanami-cli-2.0.0.alpha3/lib/hanami/cli/commands/application.rb:54:in `database'
    15: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/hanami-cli-2.0.0.alpha3/lib/hanami/cli/commands/application.rb:28:in `application'
    14: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/hanami-cli-2.0.0.alpha3/lib/hanami/cli/commands/application.rb:28:in `require'
    13: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bundler/gems/hanami-5998b4f58d84/lib/hanami/init.rb:3:in `<top (required)>'
    12: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bundler/gems/hanami-5998b4f58d84/lib/hanami/init.rb:3:in `require_relative'
    11: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bundler/gems/hanami-5998b4f58d84/lib/hanami/setup.rb:7:in `<top (required)>'
    10: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
     9: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
     8: from /home/aes/Coding/Ruby/HANAMI/hanami_2_auth_app/config/application.rb:11:in `<top (required)>'
     7: from /home/aes/Coding/Ruby/HANAMI/hanami_2_auth_app/config/application.rb:12:in `<module:Hanami2AuthApp>'
     6: from /home/aes/Coding/Ruby/HANAMI/hanami_2_auth_app/config/application.rb:15:in `<class:Application>'
     5: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bundler/gems/hanami-5998b4f58d84/lib/hanami/application/settings.rb:82:in `method_missing'
     4: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dry-configurable-0.13.0/lib/dry/configurable/config.rb:112:in `method_missing'
     3: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dry-configurable-0.13.0/lib/dry/configurable/setting.rb:79:in `value'
     2: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dry-configurable-0.13.0/lib/dry/configurable/setting.rb:147:in `evaluate'
     1: from /home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dry-types-1.5.1/lib/dry/types/type.rb:49:in `call'
/home/aes/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dry-types-1.5.1/lib/dry/types/constrained.rb:42:in `call_unsafe': nil violates constraints (type?(String, nil) failed) (Dry::Types::ConstraintError)
2 replies
postmodern
@postmodern:matrix.org
[m]
@warbot: looks like hanami 2.0.0.alpha4 clarified the postgresql:// support: https://hanamirb.org/blog/2021/12/07/announcing-hanami-200alpha4/
1 reply
postmodern
@postmodern:matrix.org
[m]
does Hanami validate the String in container['interactors.interactor_name']? What if I typo the container name, when will Hanami catch that?
1 reply
Seb Wilgosz
@swilgosz

Hi everyone, I've written a JWT authorization gem build on top of dry to easily integrate with Hanami 2.0. https://discourse.hanamirb.org/t/authentication-and-authorization-recommendations/200/6?u=swilgosz

Feel free to check it out! A cool thing is that it uses dry-effects! :D

Sebastjan Hribar
@sebastjan-hribar
Hi all, I'm again out of my comfort zone with trying to determine the best index method for our DB. Here is a SO question with two answers where the first one basically had me doubting I'm doing it right :(
postmodern
@postmodern:matrix.org
[m]
is thre a tutorial on how to setup a basic app with users and authentication?
Seb Wilgosz
@swilgosz
@postmodern:matrix.org I don't think so. It's on my roadmap to be tackled very soon though!
Sebastjan Hribar
@sebastjan-hribar
@postmodern:matrix.org I've written a post how I do it. Not a tutorial for setting up a hanami app, but rather how to use Tachiban. https://sebastjan-hribar.github.io/programming/2021/09/03/tachiban-with-hanami.html
Seb Wilgosz
@swilgosz
@sebastjan-hribar this post is about Hanami 1.x integrqtion though, isn't it?
Sebastjan Hribar
@sebastjan-hribar
@swilgosz true, 1.3 actually. I'm finally able to write a post about authorization with rokku for 1.3 as well. Then I'll move to 2.0 for both gems. Any help for 2.0 is much appreciated :)
postmodern
@postmodern:matrix.org
[m]
Appears Gitter.im is down. Wondering if that's going to cause projects to consider moving to Discord, Element, or Slack?
erthad
@erthad:matrix.org
[m]
Hi, where do partials take context from? What I need exactly is iterate over an array in a template and use partial to render the individual element with context inside that cycle. How do I do that? I didn't find any references to that in docs but only to using partials on their own.
erthad
@erthad:matrix.org
[m]
How do I get the id for foreign key without calling find on that association? I have video belong to location. If I call video.find(id) I get both .location and .location_id to be nil and I can't do a consecutive location.find because of that. How do I do this?
1 reply
I don't use aggregated call for that because I need to extract info from 2 associations and apparently you can't do 2 calls like aggregate(:location).where(id: id).map_to(Video).one in a single call — one of them doesn't seem to update parent object. or am I doing something wrong with this?
class VideoRepository < Hanami::Repository
  associations do
    belongs_to :location
    has_one :video_info
  end

  def find_with_location(id)
    aggregate(:location).where(id: id).map_to(Video).one
  end

  def find_with_info(id)
    aggregate(:video_info).where(id: id).map_to(Video).one
  end

  def find_with_info_and_location(id)   # this function doesn't populate location nor location_id
    aggregate(:location).where(id: id).map_to(Video).one
    aggregate(:video_info).where(id: id).map_to(Video).one
  end
end

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

      foreign_key :location_id, :locations, null: false
    end
  end
end

Hanami::Model.migration do
  change do
    create_table :locations do
      primary_key :id
    end
  end
end

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

      foreign_key :video_id, :videos, null: false, on_delete: :cascade
    end
  end
end
glemin5011
@glemin5011

Hi everyone, first time here and with a question! I am trying to integrate Webpack (with Babel) for react using the hanami-webpack and hanami-assets gem, but I got into some trouble with import statements.

In my application.html.erb file, i use the <%= javascript 'index' %> helper that points to my index.js file in assets, which works fine when it's pure Javascript and does not have any import statements. However, when i try to import React, it throws an error: "Uncaught SyntaxError: Cannot use import statement outside a module"

One of the solutions i found online is to put "type"="module" to package.json to ensure that all .js files are seen as modules and not CommonJS - I tried doing it, but it lead to another error with my Webpack.config.js file, which is using 'require' instead of import. I changed the file extension to Webpack.config.cjs, which resolved the error the server was throwing, but I am still stuck with 'Cannot use import statement outside of module'

Does anyone know how to solve this? Is there a good example of how to integrate React with Hanami? Thanks!

3 replies
glemin5011
@glemin5011

Hey everyone, hope you are enjoying your holidays - just fyi, after several days of tinkering with trying to integrate React as the frontend with Hanami, I came up with a basic setup that I am hoping is useful to see for anyone who is new and would like to do the same thing - I gave up on Webpack because it was unnecessarily complicated, could not get hot reload to work and the compile times were pretty long - so I used ESbuild instead. Here is a repo with a template you can use: https://github.com/glemin5011/react_on_hanami

Just be aware that it does not have any installer or anything, so things such as .env files etc. are not really transferrable to new projects - this repo is more of a demo / guide

Edit: This is for Hanami v1.3.5

Sebastjan Hribar
@sebastjan-hribar

Hey, I have this code in the views/application.rb:

def current_user_roles
      UserRepository.new.find(session[:current_user]).roles
 end

where the current_user is the user's ID. However, the view has no access to the session. How can I bypass this? The use case is limiting the displayed items as per user roles.

Sebastjan Hribar
@sebastjan-hribar
RE my question above: apps\web\views\application_layout.rb has access to session and other apps like apps\myApp\views\application_layout.rb don't. Why is that?
Sebastjan Hribar
@sebastjan-hribar
I've fixed it my making a helper module accessible to all top views.
Sebastjan Hribar
@sebastjan-hribar
I've just released Rokku 0.7.0. We found a bug when using policies for controllers with the same name. This is now fixed. I've also prepared a short blog post on the use with Hanami 1.3.
Daniel Mircea
@viseztrance
Hi. Could anyone give me a rough estimate of when we'll see version 2 beta / rc released? I'm sure this gets asked a lot but I didn't find any timetable aside from a trello board.
2 replies
Aestimo
@iamaestimo
Is anyone having an issue running bundle when working with the hanami 2 template...for some reason, mine is stuck and does not process beyond this point (ongoing now for over half an hour)
...
Running bundle install - this may take a few minutes
Fetching gem metadata from https://rubygems.org/.........
Fetching https://github.com/hanami/hanami.git
`
Aestimo
@iamaestimo

Hey Hanami experts, I've just cloned the template repo for Hanami 2, followed the steps for setting up, but when it came time to setup a new migration, I ran into the following error:

`method_missing': undefined method `session_secret' for #<Hanami::Application::Settings:0x000055af322964b8 @config=#<Dry::Configurable::Config values={}>> (NoMethodError)

What could I be doing wrong?

Hey Hanami experts, I've just cloned the template repo for Hanami 2, followed the steps for setting up, but when it came time to setup a new migration, I ran into the following error:

`method_missing': undefined method `session_secret' for #<Hanami::Application::Settings:0x000055af322964b8 @config=#<Dry::Configurable::Config values={}>> (NoMethodError)

What could I be doing wrong?

By the way, I've already setup a secret string in the .env file

5 replies
divjot124
@divjot124
hi,can anyone tell me detail reason why hanami has simple code and uses less memory.need it for proof of concept
2 replies
divjot124
@divjot124
hi,could you all tell me some great features that hanami is missing in comparison to rails.
2 replies
Sebastjan Hribar
@sebastjan-hribar
Hi all, I've just posted a question about deployment and hosting services. I'd really appreciate any advise on the topic.
Sebastjan Hribar
@sebastjan-hribar
Hi, I've enabled logging in production and when I pass the stream option I get this error: /usr/local/bundle/gems/http_router-0.11.2/lib/http_router/request.rb:10: warning: URI.unescape is obsolete.
4 replies
It was already reported by @jodosha: joshbuddy/http_router#44. Can I still use this feature, asking more from a performance point of view. The logs get written ok.