Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 30 20:07
    tiagorccabral starred hanami/hanami
  • Jul 29 14:29
    raulcoan commented #254
  • Jul 29 14:07
    fannyibz starred hanami/hanami
  • Jul 29 10:11
    AnkurVyas-BTC starred hanami/hanami
  • Jul 28 08:19
    jaypandya73 opened #645
  • Jul 26 13:04
    Ken2mer starred hanami/hanami
  • Jul 25 14:26
    hossamElfar starred hanami/model
  • Jul 24 19:28
    hpopp starred hanami/hanami
  • Jul 24 11:10

    depfu[bot] on update

    (compare)

  • Jul 24 11:10
    depfu[bot] closed #641
  • Jul 24 11:10
    depfu[bot] commented #641
  • Jul 24 11:10
    depfu[bot] labeled #644
  • Jul 24 11:10
    depfu[bot] opened #644
  • Jul 24 10:06

    depfu[bot] on update

    Update rubocop to version 1.18.4 (compare)

  • Jul 24 08:50

    depfu[bot] on update

    (compare)

  • Jul 24 08:50
    depfu[bot] closed #185
  • Jul 24 08:50
    depfu[bot] commented #185
  • Jul 24 08:50
    depfu[bot] labeled #186
  • Jul 24 08:50
    depfu[bot] opened #186
  • Jul 24 07:49

    depfu[bot] on update

    Update rubocop to version 1.18.4 (compare)

Phillip Oertel
@phillipoertel
The above also fails for a route with HTTP PATCH...
Sebastjan Hribar
@sebastjan-hribar
@phillipoertel This is just to let you know I came up with a similar - what looks an ugly - solution to find a particular controller and action in a request. I have a before block that takes an action and finds both like this:
controller = self.class.to_s.split("::")[2]
action = self.class.to_s.split("::")[3]
Árni Gunnarsson
@arni1981_gitlab
What would be the best way to play around with Hanami2, I didn't see anything on the github page or the main hanami page.
adam12
@adam12_:matrix.org
[m]
@arni1981_gitlab: I'd start with Tim's application template, since it's what will be very similar to the what the Hanami 2 CLI will generate. https://github.com/timriley/hanami-2-application-template
Phillip Oertel
@phillipoertel
I asked about a mapping from request path to Hanami app/controller/action recently. Here's what I came up with, maybe it helps someone: https://gist.github.com/phillipoertel/5d99e66d6181b037697cbfce9d0a6d5f
Marcus Pereira
@marcuxyz
thanks
hi, guys! i'm a new user of hanami. I'm creating tests with capybara, How can i to clear database for each test runned?
adam12
@adam12_:matrix.org
[m]
@marcuxyz: I'd look at database_cleaner gem.
Sebastjan Hribar
@sebastjan-hribar
@marcuxyz You could also call the clearmethod on a repo in a before or after block.
Marcus Pereira
@marcuxyz
thanks @adam12_:matrix.org and @sebastjan-hribar for help me
Mark Plaksin
@happymcplaksin_twitter
How do I add an association by ID? Apologies if this is obvious, I can't figure it out :) As an example, let's say I have a book object already and want to add it to an author? IIUC, the example add_book will create the book and doesn't work when passed an ID (or a book object) https://guides.hanamirb.org/associations/has-many/#add-and-remove
Thomas Carr
@TommyHanami
Hi I'm working my way through the guides, and am running into an issue on the interactors section. I think there's a missing instruction on updating the routes file for the create action, but even when I add a posts book => books#create to the file my tests still fail with Hanami::Routing::InvalidRouteException:
No route (path) could be generated for :books - please check given arguments
Edouard
@inouire_twitter
Can you be more specific on the syntax you use, and in which file ?
Árni Gunnarsson
@arni1981_gitlab
I'm trying out hanami-controller from the unstable branch, and this gives me the dreaded uninitialized constant Hanami::Controller::Configuration
Hanami::Controller::Configuration.new do |config|
Thomas Carr
@TommyHanami
@inouire_twitter I may have made a mistake in the previous section on the books#new form, let me correct this and see if this solves my issue.
Sebastjan Hribar
@sebastjan-hribar
Hi, I'm setting a session variable in app A and it's not available in the default Web app once redirect happens. It's available in the source app though. Is this expected behavior?
Sebastjan Hribar
@sebastjan-hribar

Hi, I'm setting a session variable in app A and it's not available in the default Web app once redirect happens. It's available in the source app though. Is this expected behavior?

I've inspected session IDs in the origin app and in the target redirected app and they are different. So how can/should I pass the session variables from one app to the next? I need this for authentication and currently it doesn't work due to this behavior.

Edouard
@inouire_twitter
Did you try sharing the same secret string for the cookie ?
Sebastjan Hribar
@sebastjan-hribar
@inouire_twitter No, and I honestly did not now this :(
I've just tried it and it works.
@inouire_twitter Thank you!
I always hate these moments of feeling stupid :)
Edouard
@inouire_twitter
@sebastjan-hribar no worry, I discovered it by chance. Not sure that it's really a feature though ^^
Sebastjan Hribar
@sebastjan-hribar
@inouire_twitter I have another problem with sessions. We have a lot of ajax calls and when sessions are enabled these calls cause the invalid csrf token error. For now I've disabled this by overwriting the verify_csrf_token?, but this seems not the way to go in production. What is the way to go about this?
Sebastjan Hribar
@sebastjan-hribar
For what is worth, we tried providing the token via the ajax call, but no success yet.
Edouard
@inouire_twitter
@sebastjan-hribar it seems that you do not generate forms with the official helper, so your forms do not include CRSF token, which is checked
The token doesn't make sense if you don't have any session, so that could be why it's working when you disable sessions
You could use form_for helper, or recreate CRSF token by yourself, or disable crsf token verification as you already do.
Sebastjan Hribar
@sebastjan-hribar

@inouire_twitter True, in these cases there are no forms generated with the official helper and sessions are enabled for the app in question. We use 1 template to build a complex editor supporting multiple ajax calls to different interactors.
Here is one code example:

$.ajax({
    type: "POST",
    url: "/wordrocket/term_records",
    datatype: "json",
    data: {term_record:
          {
      source_term: $("#tmsr-wr-input-source-term").val(),
      target_term: $("#tmsr-wr-input-target-term").val(),
      src_language: $("#tmsr-wr-select-source-language").val(),
      trg_language: $("#tmsr-wr-select-target-language").val(),
      domain_id: $("#tmsr-wr-select-term-domain").val(),
      definition: $("#tmsr-wr-textarea-term-definition").val()
          }
    },

So, is disabling csrf token verification safe in such cases?
How would we recreate and pass the token? I've been searching online for hanami (a few mentions in gitter from the Lotus times) and non-hanami references, but I still don't know how to do this.

Edouard
@inouire_twitter
About disabling the crsf check, it depends on your use case... is it sensible if a form is forged by an malicious software ? https://owasp.org/www-community/attacks/csrf
About recreating it, I'd guess that the logic is somewhere in https://github.com/hanami/helpers but I didn't find it yet
Sebastjan Hribar
@sebastjan-hribar

About recreating it, I'd guess that the logic is somewhere in https://github.com/hanami/helpers but I didn't find it yet

Yes, I've been looking there as well, but even if were to use the form helper, I don't suppose we'd have access to the token itself.

Sebastjan Hribar
@sebastjan-hribar
This seems to be the way to go, I guess.
Sebastjan Hribar
@sebastjan-hribar
By simply adding <%= csrf_meta_tags %> in the app html head the invalid csrf token error still occurs, eventhough the csrf tag and content are generated.
Sebastjan Hribar
@sebastjan-hribar
In addition to adding the above code to the app head, we have to pass it in the data:
var token = $('meta[name="csrf-token"]').attr('content')
    $.ajax({
    type: "POST",
    url: "/wordrocket/term_records",
    datatype: "json",
    data: {
    _csrf_token: token,
And it works :)
Edouard
@inouire_twitter
cool !
interesting feedback, thanks
Sebastjan Hribar
@sebastjan-hribar
And now that I've worked it out, it makes perfect sense, as usual. :)
Sebastjan Hribar
@sebastjan-hribar
I've made docs PRs for sessions and the above CSRF with UJS for future reference.
Edouard
@inouire_twitter
:thumbsup:
Kori Roys
@koriroys
Hey y'all. How would I go about setting a param programmatically if it's not set (before validating or coercing params)
Edouard
@inouire_twitter
based on what input would the params be set ?
Sebastjan Hribar
@sebastjan-hribar
This is just of the top of my head, but have you tried doing it in the beforeblock? I'm assuming you are not referring to an ajax call.
Kori Roys
@koriroys
Is there a before block for controllers? that might be what I'm looking for, ty
oh I see, it's a callback
Kori Roys
@koriroys
my use case is that certain params come in blank as "", and I have to cast them to nil in order for postgres to not explode. Didn't find a good way to do that with validations, so doing it in a before block now
pontakornth
@pontakornth
Can anyone create a new hanami project now? I encounter the wrong number of argument issue. I don'
I don't know if it is hanami issue or some other libraries. I use Ruby 3.0.0 with Rbenv. I think it's other package bug so I haven't open the issue yet.
pontakornth
@pontakornth
I created a project using 2.5.8 is fine.