Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 00:21
    hartca starred hanami/hanami
  • Oct 18 12:11
    timriley commented #1123
  • Oct 18 12:09
    timriley commented #1107
  • Oct 18 12:08
    timriley commented #1107
  • Oct 18 12:07
    timriley review_requested #1107
  • Oct 18 12:02
    timriley synchronize #1107
  • Oct 18 12:02

    timriley on unstable

    Update logger specs (compare)

  • Oct 18 11:50
    timriley synchronize #1107
  • Oct 18 11:50

    timriley on unstable

    Port configuration to dry-confi… Fix typo Co-authored-by: Luca … Move comment and 5 more (compare)

  • Oct 18 08:56

    jodosha on v1.3.5

    (compare)

  • Oct 17 09:48

    jodosha on 1.3.x

    Prepare for v1.3.5 (compare)

  • Oct 16 10:49
    timriley synchronize #1123
  • Oct 16 10:49

    timriley on elide-slice-name-in-lib

    Detect component dirs inside sl… (compare)

  • Oct 16 10:17
    timriley synchronize #1123
  • Oct 16 10:17

    timriley on elide-slice-name-in-lib

    Detect component dirs inside sl… (compare)

  • Oct 15 11:49

    jodosha on 1.3.x

    Use common method to store exce… (compare)

  • Oct 15 11:49
    jodosha closed #1031
  • Oct 15 11:48
    jodosha review_requested #1031
  • Oct 15 09:22
    jodosha assigned #1109
  • Oct 15 09:21
    jodosha assigned #1031
Sebastian Wilgosz
@swilgosz
@trafium I only know that in Hanami 2.0 settings are done via dry-configurable and dependency loading via dry-system and zeitwerk, so it's easy to inject the config as a dependency anywhere - but I see you're using 1.x which I don't know :(
jaypandya
@jaypandya:matrix.org
[m]
Does hanami(ROM) provides any way for bulk upsert? just like rails upsert_all? one way would be to write custom query so if we go that path is it possible via command?
Armin
@wuarmin
@jaypandya:matrix.org if you are using Postgresql, you can achieve it on the db level via insert on conflict. Romrb supports this via dsl(sequel under the hood) https://www.rubydoc.info/github/rom-rb/rom-sql/ROM/SQL/Postgres/Commands/Upsert
jaypandya
@jaypandya:matrix.org
[m]
Thanks but I'm using MySql and right now I've achieved it using custom query
Kazuya Hatanaka
@ippachi

Does anyone know how specify controller to nested route?

code

resources :organizations, only: [] do
  member do
    get 'me', to: 'sessions#me'
  end
end

want

$ hanami routes
           Name Method     Path                           Action

me_organization GET, HEAD  /organizations/:id/me          Web::Controllers::Organizations::Sessions::Me

actual

$ hanami routes
           Name Method     Path                           Action

me_organization GET, HEAD  /organizations/:id/me          Web::Controllers::Organizations::Me

I tried controller: option instead of to:, but I got same ouput.

Sebastian Wilgosz
@swilgosz
@Kabombom you need to use . instead #
get 'me', to: 'my.nested.action'
Or use the namespace/scope. I have presented this a bit in my second Hanami Mastery episode, feel free to use it as a reference. https://hanamimastery.com/episodes/2-listing-articles-with-hanami-view
Sebastian Wilgosz
@swilgosz
Also, I have written almost complete routing chapter for official Hanami 2.0 guides, but it's in a pull request to master waiting for other chapters to be added, feel free to check it out too! :) hanami/guides#90
jaypandya
@jaypandya:matrix.org
[m]

Hey guys
do we have any performance comparison with latest hanami app?
I'm trying to develop Hanami app + api as well and when I try to request hanami app using postman even simple "Hello world" response is taking like 200ms and where on the other hand I tried Sinatra and it serves response in 70-80 ms 🤔

am I missing something to compare it? it seems like Hanami is taking bit longer so I want to confirm
I might be wrong in this comparison

Sebastian Wilgosz
@swilgosz
I am not sure. Jeremy evans had published recently an update of benchmark between roda and other frameworks, see: https://roda.jeremyevans.net/ but I believe he compared it against latest official version, which is 1.3
But there is comparison with hanami-api though @jaypandya:matrix.org . There is another benchmark on the official hanami blog, but only comparing Hanami router. We definitely will prepare some benchmarks but I don't think it makes sense to spend time on it now, as there will be performance improvements in the upcoming releases.
jaypandya
@jaypandya:matrix.org
[m]
Thanks @swilgosz for looking into this but I dig into this and find out that on every request it was loading code every time so when I run server with --no-code-reload argument it worked perfectly and got response in 20-30ms so it looks good
Sebastian Wilgosz
@swilgosz
@jaypandya:matrix.org thanks!
jaypandya
@jaypandya:matrix.org
[m]
has anyone tried changing default ROM dataset as I want to remove default ordering on primary key for some of my queries
as https://rom-rb.org/3.0/learn/sql/relations/ ROM relations class says that by default it will select all DB columns and it will perform ORDER BY operation on table primary key
so I'm trying to change this dataset for my Repositories but I'm not able to override default dataset
Raul Victor Coan
@Wynteres
Hey guys, anyone knows how to use the view to render JSON without it triggering that freaking safety feature that converts " to " ?
Maxi
@mvadora_twitter
Hey guys! I'm new here. So I have some questions to ask you.
  1. How can I start with hanami? -> Currently I'm reading docs and understanding the hows and the whys
  2. Why should I choose hanami instead of rails to build a new application?
  3. What is the ideal or perfect project for hanami?
    Thanks!
Sebastjan Hribar
@sebastjan-hribar
Hi all, does anyone know how to add unique constraint on an combination of columns like so: add_unique_constraint(:column_1, :column_2). This, however, returns no implicit conversion of Symbol into Hash.
Sebastian Wilgosz
@swilgosz
@mvadora_twitter I suggest to either wait a little bit, or try to focus on sources covering Hanami 2.0, like my Hanami Mastery project. https://hanamimastery.com/. I am in the process of creating PDF about differences between Hanami and Rails, and also some guides when and how to switch. I have also written an article talking about my experience in switching from Rails (https://www.useo.pl/blog/2021/07/trying-hanami-in-microservices). For philosophy I recommend the official guides (https://guides.hanamirb.org). The Hanami Guides for 2.0 are in progress by me (hanami/guides#90). For direct contact and help I can recommend supporting me on Github, I prioritize questions and topics of my GH sponsors when preparing new HM episodes and articles. Also I give access to my private, and beta projects source code for them. Finally, there is a bookshelf repository in Hanami gh account, where you can see by an example a complete application.
Maxi
@mvadora_twitter
@swilgosz Hi, thanks for the answer, I definitely gonna take a look at each stuff that you've mentioned.
Sebastjan Hribar
@sebastjan-hribar

Hi all, does anyone know how to add unique constraint on an combination of columns like so: add_unique_constraint(:column_1, :column_2). This, however, returns no implicit conversion of Symbol into Hash.

it seems to work by passing in an array of column names. Also, to remove the previously added unique constraint on a column use the drop_constraintmethod and pass it the constraint name, created by the add_unique_constraint.

Sebastian Wilgosz
@swilgosz

@sebastjan-hribar does this help you? It seems you need to pass an array of columns, try to wrap it with []

https://github.com/jeremyevans/sequel/blob/master/doc/schema_modification.rdoc#index-

Sebastjan Hribar
@sebastjan-hribar
@swilgosz yes, I can implement the new constraint by passing the array of columns, but I also had to drop the previous one, which I couldn't figure out. I've ended up just dropping the db and adjusting the previous migration. With seeding in place we have the db back for dev in no time :)
Dino Koutrouzas
@dino-koutrouzas

@sebastjan-hribar had to do this the other day by using drop_constraint with the name of the constraint, which in our case was something like drop_constraint :table_name_first_column_second_column_key

https://sequel.jeremyevans.net/rdoc/classes/Sequel/Schema/AlterTableGenerator.html#method-i-drop_constraint

Brendan
@b-murphy

Hey All :wave:

I've recently hit an oddity with my spec within a newly create hanami app.

Basically we have controllers which will use the handle_exception => :do_a_thing

To test this we are using expect { action.call(params) }.to raise_error(exception, message)

Which works nicely; But the issue is that we can't seem to configure handle_exceptions correctly to false when running request specs; we've tried handle_exceptions ENV.fetch('HANDLE_EXCEPTIONS', true) and using allow(ENV).to receive(:fetch).with('HANDLE_EXCEPTIONS') But something within the pre-booting of the application.rb within this doesn't listen to this or something else we perhaps are missing?!

Having a dig though hanami's own specs we noticed hanami/devtools doing something to RSpec::Support::Env which looks like it would cover the case; but haven't explored yet; but seems like a relatively simple problem we perhaps have just missed!

Any help would be greatly appreciated!

Artemiy Solopov
@art-solopov
Hi all.
Sorry if this question is explained elsewhere.
Can I render a partial from a view/helper? render partial: partial_name in a helper method throws an ArgumentError.
Sebastjan Hribar
@sebastjan-hribar
@art-solopov I'm not sure what the problem would be, but we keep partials in apps\templates\shared, name them like _notice.html.erb and invoke them in the template like <%= render partial: 'shared/notice'%>.
Sebastjan Hribar
@sebastjan-hribar
I've put together a small blog post for how I use Tachiban. I'm comparing the use across my apps and I realized this is something that would be useful from the start, but I haven't put it in the readme.
Anyway, I hope it will be useful to someone else as well. I'll update if/when I find any errors and I'll write one for Rokku.
Sebastian Wilgosz
@swilgosz
Hi, I have published a short YT video guide about mapping Rails to Hanami, it may help to quickly grasp basic hanami concepts for people coming from the Rails world:).
Jeffrey 'jf' Lim
@jf
does anybody know if there is a way to get a list of all the entities defined in Hanami?
Sebastian Wilgosz
@swilgosz
Don't know if there is any shortcut but here are few ideas https://stackoverflow.com/questions/2393697/look-up-all-descendants-of-a-class-in-ruby
Jeffrey 'jf' Lim
@jf
thank you, Sebastian! that helps!
postmodern
@postmodern:matrix.org
[m]
Hi, I'm looking for an example app that uses both hanami-model (for app models) and another database via ActiveRecord.
postmodern
@postmodern:matrix.org
[m]
:point_up: Edit: Hi, I'm looking for an example app that uses both hanami-model (for app models) and another database via ActiveRecord. The other database would be managed by AR models from another gem. I'm guessing I'd need to load the gem's AR migrations in db/migrate and initialize ActiveRecord somewhere in config/...?
postmodern
@postmodern:matrix.org
[m]
Hmm it may reduce future contributor confusion if I just used AR for both databases.
Sebastian Wilgosz
@swilgosz
@postmodern:matrix.org First of all, keep in mind, that it's unclear if Hanami-Model will be used in Hanami 2.0. There is a big chance, that ROM 6.0 will be used directly. Therefore, please share the more insights why do you think that AR is needed to connect to a database? In ROM you can create migrations based on the current database schema, no need to import AR migrations and work with it. Then, you can create your ROM entities to infer from the database structure, just table names need to match. You could use ROM entities to just connect to multiple databases.
postmodern
@postmodern:matrix.org
[m]
well I want to have a library of DB models+migrations separate from the web app. Previously I used DataMapper for this library but that is defunct now. ROM seems a bit heavy, esp for CRUD and crafting SQL queries. AR has more users (due to Rails) and is more accessible for other developers who might contribute to the library or the web app. If I used the library in the app, than the library migrations would also need to be called along with the app's migrations. Also, the app would need to define it's own models for User, etc, separate from the library. So if I wanted to make it easy for contributors to contribute to both the db library and the app, than it seems consistent to use AR in both.
postmodern
@postmodern:matrix.org
[m]
:point_up: Edit: well I want to have a db library of DB models+migrations separate from the web app. Previously I used DataMapper for this library but that is defunct now. ROM seems a bit heavy, esp for CRUD and crafting SQL queries. AR has more users (due to Rails) and is more accessible for other developers who might contribute to the library or the web app. If I used the library in the app, than the library migrations would also need to be called along with the app's migrations. Also, the app would need to define it's own models for User, etc, separate from the library. So if I wanted to make it easy for contributors to contribute to both the db library and the app, than it seems consistent to use AR in both.
Sebastian Wilgosz
@swilgosz
Fair points. I do believe that the pool of ROM users will increase a lot after Hanami 2 is released, however I understand your motives. Thanks for the explanation and I am sorry for not being too helpful here.
@postmodern:matrix.org you can also try to ask on https://discourse.hanamirb.org/, the core team members are a bit more active there and the whole Hanami communication strategy is moving the attention more to forums (discourse, StackOverflow) than chats.
postmodern
@postmodern:matrix.org
[m]
oh cool, thanks!
ume-san
@ume-san:matrix.org
[m]
I have started using Hanami 1.3, and it's really great! I am also interested in 2.0. As far as I see an example of 2.0, https://github.com/hanami/hanami-2-application-template , there's no 'apps' directory. 'Slices' directory seems to be an alternative in 2.0. It would be great if there's an explanation about the difference between apps in 1.3 and slices in 2.0. Could someone explain it ?
Sebastian Wilgosz
@swilgosz
Yes, the slices is a replacement for apps. I do that have comparison of 2.0 vs 1.3 just yet. I an working on official guides for 2.0, and one of the chapters will be about upgrade notes, but this will he done as a very last part. I did publish the comparison of Rails and Hanami 2 architecture recently with YT video guide included. Feel free to check it out! https://hanamimastery.com/episodes/8-rails-vs-hanami-mapping-frameworks
Also feel free to subscribe to my Hanami Mastery channel and newsletter to get more learning resources about Hanami 2 and cirresponding gem families:)
Oh, sorry for the typo, I meant: I don't have comparison of Hanami 2 and 1.3, and I don't think there is anything official atm.
ume-san
@ume-san:matrix.org
[m]
@swilgosz: Thank you for your resources! Hanami Mastery is really helpful. I understand Hanami intends various abstractions, and it can be better than Rails.
I feel 2.0 intends more abstractions than 1.3, and I do not understand it and am still confused about it.
For example, 'show' action and 'show' view exist in very deep places, /slices/{main/lib/}main/actions/home/show.rb and /slices/{main/lib/}main/views/home/show.rb (curly braces are used just to emphasize). I do not understand the abstraction of {main/lib} part. From the view of 1.3, /slices/main/actions/home/show.rb and /slices/main/views/home/show.rb may be enough??
I hope there will be some explanations about these newly introduced abstractions or concepts in 2.0 !
Sebastian Wilgosz
@swilgosz
@ume-san:matrix.org this unnecessary redundant namespacing is exactly what Tim Riley worked on last month! The recent dry-system release solves exactly this problem and the next Hanami 2 alpha release will have simplified file structure:)