Forum https://discourse.hanamirb.org – Code of Conduct http://hanamirb.org/community/#code-of-conduct
adam12 on pg-env-variables
Revert "Log ENV" This reverts … Never prompt for password in Gi… (compare)
adam12 on pg-env-variables
Log ENV (compare)
adam12 on pg-env-variables
Pass environment variables to e… (compare)
adam12 on pg-env-variables
fixup! Pass env to system in po… (compare)
adam12 on pg-env-variables
Pass env to system in postgresq… Remove manual PGPASSWORD settin… Call postgresql command with en… (compare)
depfu[bot] on update
Update rubocop to version 1.11.0 (compare)
depfu[bot] on update
HI, I noticed a problem during migration execution, basically I've got migration like this:
Hanami::Model.migration do
change do
create_table :users do
primary_key :id
column :email, String, null: false
column :encrypted_password, String
column :phone_number, String
column :created_at, DateTime, null: false
column :updated_at, DateTime, null: false
end
end
end
When I run it, it shows me following snippet
[hanami] [ERROR] PG::UndefinedTable: ERROR: relation "schema_migrations" does not exist
LINE 1: SELECT NULL AS "nil" FROM "schema_migrations" LIMIT 1
^: SELECT NULL AS "nil" FROM "schema_migrations" LIMIT 1
[hanami] [INFO] (0.042149s) CREATE TABLE "schema_migrations" ("filename" text PRIMARY KEY)
[hanami] [ERROR] PG::UndefinedTable: ERROR: relation "schema_info" does not exist
LINE 1: SELECT NULL AS "nil" FROM "schema_info" LIMIT 1
^: SELECT NULL AS "nil" FROM "schema_info" LIMIT 1
But, when I add null: true
to encrypted_password
and phone_number
everything works smoothly. Both in hanami guide and in rom-sql I see this is an optional attribute. Anyone has idea what can cause this issue?
schema_migrations
and schema_info
exist, if they don't they are created.
Hi, thank you @inouire_twitter and @kaikuchn for responding me. I'll verify if there is no invisible char when in the evening. Also, this is the only migration I have.
About the errors and checks - what I see is in related database schema_migrartions
table is being created but no schema_info
is present. Also, running hanami db prepare
once again, on already migrated database, the output of execution remains the same.
Hello, I'm using hanami-api and hanami-controller (action) as standalone gems. Now I observe an issue and hope somebody can help me. I have a GraphQL-controller, which should use the Authorization-Header
to authenticate. So in the controller I get the header-value as described in the docs:
bearer_token = request.env['HTTP_AUTHORIZATION']
this works for the first request after application-startup. If I change the header at the client application (i.e. to an invalid token). The controller gets always the token from the first request. So the header get cached. If I investigate the whole rack.env
,
ap(request.env)
I get something like this:
{
"rack.version" => [
1,
6
],
"rack.errors" => #<Rack::Lint::ErrorWrapper:0x000055bd2bc60b68 @error=#<IO:<STDERR>>>,
"rack.multithread" => true,
"rack.multiprocess" => false,
"rack.run_once" => false,
"SCRIPT_NAME" => "",
"QUERY_STRING" => "query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D",
"SERVER_PROTOCOL" => "HTTP/1.1",
"SERVER_SOFTWARE" => "puma 5.0.4 Spoony Bard",
"GATEWAY_INTERFACE" => "CGI/1.2",
"REQUEST_METHOD" => "GET",
"REQUEST_PATH" => "/graphql",
"REQUEST_URI" => "/graphql?query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D",
"HTTP_VERSION" => "HTTP/1.1",
"HTTP_HOST" => "localhost:9292",
"HTTP_USER_AGENT" => "Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0",
"HTTP_ACCEPT" => "application/json, text/plain, */*",
"HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.5",
"HTTP_ACCEPT_ENCODING" => "gzip, deflate",
"HTTP_AUTHORIZATION" => "Bearer old_token",
"HTTP_CONNECTION" => "keep-alive",
"HTTP_COOKIE" => "MicrosoftApplicationsTelemetryDeviceId=cd5cc910-fc4f-436e-8ea7-f93b17fd7093; MicrosoftApplicationsTelemetryFirstLaunchTime=2020-01-08T14:59:29.306Z",
"puma.request_body_wait" => 0,
"SERVER_NAME" => "localhost",
"SERVER_PORT" => "9292",
"PATH_INFO" => "/graphql",
"REMOTE_ADDR" => "127.0.0.1",
"puma.socket" => #<TCPSocket:(closed)>,
"rack.hijack?" => true,
"rack.hijack" => #<Proc:0x000055bd2bc60ff0 /home/armwur/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/lint.rb:567>,
"rack.input" => #<Rack::Lint::InputWrapper:0x000055bd2bc60b90 @input=#<Puma::NullIO:0x000055bd2c024a88>>,
"rack.url_scheme" => "http",
"rack.after_reply" => [],
....
@_env={"rack.version"=>[1, 6], "rack.errors"=>#<Rack::Lint::ErrorWrapper:0x000055bd2ce5e158 @error=#<IO:<STDERR>>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "HTTP_AUTHORIZATION"=>"Bearer new_token", "QUERY_STRING"=>"query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 5.0.4 Spoony Bard", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/graphql", "REQUEST_URI"=>"/graphql?query=query%20($id:%20ID!)%20%7B%0A%20%20airport(id:%20$id)%20%7B%0A%20%20%20%20id%0A%20%20%20%20iataCode%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%22id%22:1%7D", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_HOST"=>"localhost:9292", "HTTP_USER_AGENT"=>"Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0", "HTTP_ACCEPT"=>"application/json, text/plain, */*", "HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.5", "HTTP_ACCEPT_ENCODING"=>"gzip, deflate", "HTTP_CONNECTION"=>"keep-alive
Instantiating a request for each incoming HTTP request can lead to minor performance degradation. As an alternative, please consider getting the same information from private action methods like accept? or from the raw Rack environment params.env.
params.env['HTTP_AUTHORIZATION']
returns everytime the current Auth-Header.
structure
file. This file usually only exists after you have run migrations successfully at least once.bundle exec hanami db create
and bundle exec hanami db migrate
manually instead of hanami db prepare
(which should just do those two steps for you).
Hi, I have a question. I like to disable hanami/model's sql log on production environment.
Looking at this PR: hanami/model#368, seems it is not possible to disable sql log. Correct?
And I have found a similar question on the chat: https://gitter.im/hanami/chat/archives/2019/05/22?at=5ce506d76366992a94ff0162, but cloud not find any helpful hacks.
Any idea why I would have problems with loading css/js in production on Heroku? Everything works okay locally with RACK_ENV=development bundle exec hanami server
. When I use RACK_ENV=production
locally, when I turned off the default configurations for production
, (e.g.fingerprint
, compile
,subresource_integrity
since I'm not using a CDN yet) it works.
But in actual production, my app doesn't load any of my CSS/JS. I'm using hanami-bootstrap
for reference. I also have SERVE_STATIC_ASSETS="true"
in my production ENV variables. I checked the logs and I don't see anything failing. Precompiling assets seems to work fine with rake
. Any ideas?
Hi! Is it possible to change handle_exceptions
for the application dynamically? I want to test if the exception handling is working as I expect, but the exception handling is deactivated by default.
If I active it, then I don't errors (like typos) while performing other tests.
If I try change it before running the test, the configuration does not react to the change.
# Before hook in my test to check the exception handling
before do
Api::Application.configure :test do
handle_exceptions true # This does not have any effect on the configuration
end
end
hey folks, struggling a bit with preloading associations. How do I preload nested associations? I see that Rom supports doing combine(*nested)
but I can't manage to make it work on my hanami Repo
politicians
.combine(occupations: [:role])
.where(id: id)
.map_to(Politician)
.one
it tries to find roles
instead, I dont understand :roles doesn't exist in ROM::RelationRegistry registry
.
Then I tried using join
but I simply can't manage to make the where
to workout as I dont know how to reference politicians.id
. If I do .where(id: id)
it doest work as a SQL problem. If I do .where("politicians.id" => id)
it doesnt work because Rom/Hanami will use simple quotes for building the query as like WHERE('politicians.id' = 1)
and in Postgres that's a problem.
I also tried aggregates(occupations: [:role])
but it falls on the problem as the first. It tries to find roles
association and it doesn't exist because an occupation has_one :role.
Anyway, isn't there anyway to preload nested associations on Hanami?
roles
instead of role
only after I map the association has_one :role
on the Occupation repo. Before if tries role
(singular) but it can't find anyway
B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/definition.rb:33:in
initialize': wrong number of arguments (new'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/options.rb:17:in
with'constructor'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:41:in
block in <module:Types>'each'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:40:in
<module:Types>'<module:Dry>'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-types-0.12.3/lib/dry/types/core.rb:3:in
<top (required)>'require'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'<top (required)>'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'require'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry/validation/input_processor_compiler.rb:1:in
<top
(required)>'require'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'<top (requi
red)>'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'require'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry/validation/schema.rb:14:in
<top (required)>'require'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'<top (required)>'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'require'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/dry-validation-0.11.2/lib/dry-validation.rb:1:in
<top (required)>'require'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'<top (required)>'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'require'
from B:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/hanami-1.3.3/lib/hanami/frameworks.rb:2:in
<top (required)>'require'
from <internal:B:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
require'