Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 11 21:49
    maxloh starred hanami/hanami
  • Dec 11 20:41
    IvanShamatov synchronize #1021
  • Dec 11 20:08
    wout forked
    wout/model
  • Dec 11 20:04
    wout forked
    wout/hanami
  • Dec 11 14:35
    jodosha assigned #1021
  • Dec 11 08:50
    IvanShamatov synchronize #1021
  • Dec 11 05:34

    timriley on application-settings

    Make container aware of lib loa… (compare)

  • Dec 11 05:24

    timriley on application-settings

    Allow settings to be nil It sh… Fix Syntax (compare)

  • Dec 11 05:09

    timriley on application-settings

    Add rough cut of settings suppo… Be more proactive loading doten… Remove unnecessary eval and 19 more (compare)

  • Dec 10 13:51
    TatsukiMinami starred hanami/hanami
  • Dec 10 13:43
    IvanShamatov synchronize #1021
  • Dec 09 21:27
    IvanShamatov synchronize #1021
  • Dec 09 21:27
    IvanShamatov edited #1021
  • Dec 09 21:21
    IvanShamatov opened #1022
  • Dec 09 20:59
    IvanShamatov opened #1021
  • Dec 09 20:49
  • Dec 09 12:20
    s4na starred hanami/hanami
  • Dec 09 10:28

    mereghost on update-dry-types

    Update code for dry-types 1.2.2 (compare)

  • Dec 09 10:14

    mereghost on update-dry-types

    Update code for dry-types 1.2.2 (compare)

  • Dec 08 12:06
    sebastjan-hribar opened #1020
Sebastjan Hribar
@sebastjan-hribar
@kaikuchn Sure, I'll draft some pseudo code for the files and code I think would correspond for such scenario.
EGORIDI
@EGORIDI
Hi folks. I'm getting started with the tutorial and could'nt migrate the database schema. When I try I get a "SQLite3 SQLException: no such table: schema_migrations: SELECT NULL AS 'nil' FROM schema_migrations LIMIT 1" as well as " SQLite3::SQLException: no such table: schema_info: SELECT NULL AS 'nil' FROM schema_info LIMIT 1".
When I try to prepare the database with "HANAMI_ENV=test bundle exec hanami db prepare " I get "HANAMI_ENV=test : The term 'HANAMI_ENV=test' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again." Does anyone know how can I get through it?
Paweł Świątkowski
@katafrakt
@EGORIDI Are you using in-memory SQLite db? IIRC it does not work now, you should use persisted one.
Kai Kuchenbecker
@kaikuchn

When I try I get a "SQLite3 SQLException: no such table: schema_migrations: SELECT NULL AS 'nil' FROM schema_migrations LIMIT 1" as well as " SQLite3::SQLException: no such table: schema_info: SELECT NULL AS 'nil' FROM schema_info LIMIT 1".

It's okay for that table to not exist, it should simply be created subsequently. Sadly, this "error" is printed to the console and confuses people.
What @katafrakt said still applies.

EGORIDI
@EGORIDI
Thanks, I'll try it.
Emir Fernandes da Ponte
@EmirFernandes_gitlab
Hello!
Kai Kuchenbecker
@kaikuchn
Hi
Danny Santos
@DannySantos
Does anybody have any advice on clearing the params after an AJAX request? Because the template that gets rendered comes directly from (for example) the create view/controller, it still has the params that were submitted in the post request. This causes issues when, for example, re-rendering a form upon success. You don’t want the form builder to attempt to fill in the fields with the params.
Kai Kuchenbecker
@kaikuchn
Redirect on success instead of re-rendering the form. That way the user can even refresh the page without triggering a post again.
Danny Santos
@DannySantos
@kaikuchn but doesn’t that somewhat defeat the point of AJAX? The great benefit of asynchronous apps is that we can create a seamless user experience as well as make the app more efficient by not having to reload the page or redirect.
Kai Kuchenbecker
@kaikuchn
I'm not entirely sure what you're doing or trying to accomplish. Are you sending chunks of HTML and interpolate them into your existing DOM? If all you want to do after submitting a form via ajax is to clear it, why not just clear it client-side? Server could just give you a success response without a body in that case.
Again, not really sure what you're doing.
Danny Santos
@DannySantos
Generally what my AJAX requests do is either return a failure or success. If it’s a failure I simply use JS to display a notification. Upon success however, I generally display a notification and also re-render a section of the page, ususally by assigning the contents of a partial to a JSON object and then replacing the page section with JS.
smarthouseprojectdotorg
@smarthouseprojectdotorg
Hi I'm new to Hanami, is it a right place to ask questions? :)
smarthouseprojectdotorg
@smarthouseprojectdotorg

Got a problem with using repositories and the code below returns undefined method `all' for ROM::Relation::Composite It seems query methods are not chainable?

class UsersRepository < Hanami::Repository
def yesterday_and_older
users.where{ created_at < (DateTime.now() - 1.0) }.all
end
end

Could someone shed a light on it?

unleashy
@unleashy
@EGORIDI by the way, this error "HANAMI_ENV=test : The term 'HANAMI_ENV=test' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again." is just a Windows weirdness; you can't set environment variables before the command like you can in linux
the workaround is to set the env var before then unset it after:
> set HANAMI_ENV=test
> (do hanami stuff for the test env)
> set HANAMI_ENV=
(yes, it's extremely annoying)
maybe the hanami docs need to be updated to tell Windows users about that...
Sebastjan Hribar
@sebastjan-hribar
@smarthouseprojectdotorg You don't need/can't call the all method in your case. It's implemented so you can call allon the repository like UserRepository.new.alland it returns all entities. Your yesterday_and_older will return all entities corresponding to your condition.
Sebastjan Hribar
@sebastjan-hribar

I have a problem with updating a record. This is the very basic update action:

module Godmode
  module Controllers
    module ContactPersons
      class Update
        include Godmode::Action

        def call(params)
          @contact_person = ContactPersonRepository.new.update(params[:id], params[:contact_person])
          redirect_to "/godmode/contact_persons"
        end
      end
    end
  end
end

Up until I hit the submit button everything works. The updated params show up in the server log as well.
I also notice that no matter what I use to redirect to, it always goes to http://localhost:2300/godmode/contact_persons?id=3except for the 3 part of course.

In my routes I have only
resources :clients
resources :contact_persons
Sebastjan Hribar
@sebastjan-hribar
The entity is not updated and the params actually are not passed to the action.
Sebastjan Hribar
@sebastjan-hribar
I've tried whitelisting the params, but no luck. Any ideas how to debug it or what I'm doing wrong?
Sebastjan Hribar
@sebastjan-hribar

The params.inspect in my update action, called by the spec, returns:

#<Godmode::Controllers::ContactPersons::Update::Params:0x000055fe732aa7c0 @env={"REQUEST_METHOD"=>"GET"}, @input={}, @result=#<Dry::Validation::Result output={} errors={:id=>["is missing"], :contact_person=>["is missing"]}>, @params={}, @errors={:id=>["is missing"], :contact_person=>["is missing"]}>

It confirms nothing gets to the action, but why is the request method GET?

Sebastjan Hribar
@sebastjan-hribar
Also, create, show and index all work fine.
Paweł Świątkowski
@katafrakt
@sebastjan-hribar I would start with adding some validation and checking if it passes for params
You say params are not passed to the action. Then how does the code that leads to execution of this action looks? Also what is in Godmode::Action?
Sebastjan Hribar
@sebastjan-hribar
@katafrakt Hi, here's a gist of the relevant code. I've followed same patterns as in my previous app, the main difference being is that here are many apps (Godmode being one of them) under the main project tmsr. The other app only has the webapp.
https://gist.github.com/sebastjan-hribar/76bcd650c01837f67ffb143e3470d839
Paweł Świątkowski
@katafrakt
@sebastjan-hribar form_for :contact_person, routes.contact_persons_path(id: contact_person.id) - why contact_persons_path and not contact_person_path? You're probably calling different action (create perhaps?). Or I don't understand your routing ;)
Kai Kuchenbecker
@kaikuchn

Generally what my AJAX requests do is either return a failure or success. If it’s a failure I simply use JS to display a notification. Upon success however, I generally display a notification and also re-render a section of the page, ususally by assigning the contents of a partial to a JSON object and then replacing the page section with JS.

I thought as much. If that is how you want to handle things, then you will have to make sure that you don't pass the request params to the rendering of the partial, just replace it with an empty hash I guess.

@smarthouseprojectdotorg Yes, this is the right place. Welcome to Hanami!
As Sebastjan pointed out all gives you a result set, which is all records in your repository. If you have a look at the guides you will find out WHY you cannot chain methods. This is intentional! In general I recommend perusal of the guides since Hanami is different from what, say, a Rails Developer is used to.
Sebastjan Hribar
@sebastjan-hribar
@katafrakt I knew it has to be something stupid I did and you found it :smile: Thank you!
Works like a charm now
smarthouseprojectdotorg
@smarthouseprojectdotorg
@sebastjan-hribar @kaikuchn
Thank you! So using where() or where{} gives the result set right away and then I can use it or say .delete it. Does it sound correct?
Danny Santos
@DannySantos

@kaikuchn That’s one of two ideas we’ve been working with. We implemented it as a view method on :js views:

def params
  return @_params if @_params

  @_params = locals[:params].dup
  @_params.to_h.keys.each{ |k| @_params.to_h.delete(k) }
  @_params
end

The other idea we’re playing with is adding an option to the form_for method which tells it not to prioritise the params. There’s a discussion about it going on in this issue if anyone is interested:

hanami/helpers#149

smarthouseprojectdotorg
@smarthouseprojectdotorg

Asked the below in the forum but it seems this chat works better!
I saw a discussion about mounting an app to a domain and that followed with an update but it seems to not work with a subdomain as stated in the docs. It only works if I specify a full domain name. Is it expected or a bug? My workaround is to put a domain name to env and fetch it from ENV in environment.rb but that would not be needed to do if mounting worked with a subdomain name.

This does not work (order DOES matter but it’s not a problem, yet took time to realize it!):

mount MyApp1::Application, host: ‘app1’, at: ‘/’
mount MyApp2::Application, at: ‘/app2’
mount Web::Application, at: ‘/’

This works:

mount MyApp1::Application, host: ‘app1.domain.com’, at: ‘/’
mount MyApp2::Application, at: ‘/app2’
mount Web::Application, at: ‘/’

A workaround:

mount MyApp1::Application, host: ENV.fetch(‘MY_DOMAIN_NAME’), at: ‘/’
mount MyApp2::Application, at: ‘/app2’
mount Web::Application, at: ‘/’

The domain name differs for development, production and also my local development hence the question. Thank you!

Kai Kuchenbecker
@kaikuchn
@smarthouseprojectdotorg hanami/router#104 is the PR that implemented the feature. It wasn't touched since (at least that I can tell). I'd therefore say that the docs are wrong.
Surya Poojary
@Surya-risingsun
Guys I don't know Rspec or BDD
Can I still start with hanami
Sebastjan Hribar
@sebastjan-hribar
@poojx I use minitest myself. Just specify it when creating a new project: https://guides.hanamirb.org/command-line/project/#testing-framework
Sebastjan Hribar
@sebastjan-hribar
A word of caution, yesterday I had to recreate my gemfile.lock and the updates seem to affect pluralization of contact_person. I created the table contact_persons, but the now broken tests complain about not finding contact_people :smile: I'm aware of this plural form, however it doesn't seem natural for this context. Anyway, I'm changing it to simply contacts what I should have done in the first place.
Sebastjan Hribar
@sebastjan-hribar
Auto generated tests for minitest report deprecated warning for global use of must_equal and global use of must_include which will fail in Minitest 6. I'm using the latest version 5.13.0. Where should I check if this is already being reported?
Kai Kuchenbecker
@kaikuchn
I think here https://github.com/hanami/hanami/issues would be appropriate
Jeff Dickey
@jdickey
Hey, folks: has anyone successfully used Semaphore CI to build a Dockerised Hanami app? I'm running into a database-access problem that has me profoundly confused
Kai Kuchenbecker
@kaikuchn
No, I'm using CircleCI. However, I may still be able to help you out
Jeff Dickey
@jdickey

Thanks, @kaikuchn. I'm having a problem getting Semaphore's Postgres service to connect with my app (which has already passed non-Docker tests) using their standard Postgres service, which is activated by the command step sem-service start postgres. The CI log indicates that it starts successfully, and a subsequent sem-service status postgres confirms this. Their (Rails+Postgres) doc at https://docs.semaphoreci.com/article/73-ruby#database-configuration indicates that setting the DATABASE_URL environment variable in the Dockerfile (which Hanami also uses for the same purpose, in the same format) to, e.g., postgresql://postgres:@0.0.0.0/semaphore_hanami_poc should Just Work. However, running bin/hanami db drop acts as though Postgres isn't running.

From the log:

Step 11/15 : RUN bin/hanami db drop || true

 ---> Running in 291c9f4b9efb

dropdb: could not connect to database template1: could not connect to server: Connection refused

        Is the server running on host "0.0.0.0" and accepting

        TCP/IP connections on port 5432?

/usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator/postgres_adapter.rb:99:in `block in call_db_command'

        /usr/local/lib/ruby/2.6.0/open3.rb:219:in `popen_run'

        /usr/local/lib/ruby/2.6.0/open3.rb:101:in `popen3'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator/postgres_adapter.rb:98:in `call_db_command'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator/postgres_adapter.rb:44:in `drop'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator.rb:295:in `drop'

        /usr/local/bundle/gems/hanami-model-1.3.1/lib/hanami/model/migrator.rb:76:in `drop'

        /usr/local/bundle/gems/hanami-1.3.2/lib/hanami/cli/commands/db/drop.rb:26:in `drop_database'

        /usr/local/bundle/gems/hanami-1.3.2/lib/hanami/cli/commands/db/drop.rb:17:in `call'

        /usr/local/bundle/gems/hanami-1.3.2/lib/hanami/cli/commands/command.rb:85:in `call'

        /usr/local/bundle/gems/hanami-cli-0.3.1/lib/hanami/cli.rb:57:in `call'

        /usr/local/bundle/gems/hanami-1.3.2/bin/hanami:6:in `<top (required)>'

        bin/hanami:29:in `load'

        bin/hanami:29:in `<main>'

The Dockerfile continues on to the next step (because we ORed true with the previous one), and encounters the identical error when it attempts to run bin/hanami db create

Ideas?

Kai Kuchenbecker
@kaikuchn
In their example on managing databases they don't actually connect to the DB from within another container but from within the same "command" which I assume is run in a container.
They also say that services are local to such a block... Can you maybe show the relevant part of the semaphore config file?
Is maybe this the workflow you want to have? (I.e., instead of using sem-services start and link containers)
Jeff Dickey
@jdickey
@kaikuchn I've put the two pipeline configs up at https://gist.github.com/jdickey/0bd4113e018befb97d62bf7db369bb5b
  • docker-build.yml is the one that's failing; it runs after semaphore.yml;
  • semaphore.yml runs CI tests against a non-Dockerised copy of the app