Forum https://discourse.hanamirb.org – Code of Conduct http://hanamirb.org/community/#code-of-conduct
solnic on improve-middleware-loading
Rely on autoloading in rack_mon… Remove unneeded rubocop:disable Fix Hanami.rack_app to return a… (compare)
timriley on combine-slices-and-applications-2
Expand slice routes tests Update example description Support external slices (compare)
timriley on combine-slices-and-applications-2
Move slice settings spec into b… Add example for nil router/rout… (compare)
timriley on combine-slices-and-applications-2
Fix up check for routes Raise better error (compare)
timriley on combine-slices-and-applications-2
Pass router properly Return nil router if no routes … Use argument forwarding syntax (compare)
timriley on combine-slices-and-applications-2
Slices should prepare themselve… Boot the application slice befo… Remove redundant setting of root and 3 more (compare)
depfu[bot] on update
Update rack-test to version 2.0… (compare)
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
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.
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
`
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
Hi, I've encountered another issue when deploying to production. I'm deploying with docker on client's server and I have bundle exec hanami assets precompile
in my docker compose right before starting the server. However, not all assets are in the public
folder.
If I run precompile before the build and don't run precompile with compose then I get the Internal Server Error
.
If I run precompile in a running container the assets are again not served.
I have the option to serve static assets set to true in my .env.production
.
As per usual, what am I doing wrong?
Is it possible to have raw sql like this:
def find_by_segment_match(source_text_for_lookup, source_lang)
segments
.read("set pg_trgm.similarity_threshold TO 0.4;
SELECT *, SIMILARITY(segments.content, '#{source_text_for_lookup}') AS similarity
FROM segments
JOIN translation_records
ON segments.id = translation_records.source_segment_id
LEFT JOIN segments AS target_segments
ON translation_records.target_segment_id = target_segments.id
WHERE segments.language_id = #{source_lang} AND segments.content % '#{source_text_for_lookup}'
ORDER BY segments.content <-> '#{source_text_for_lookup}';").map_to(Segment)
end
and to map it to a entity, in my case Segment
. I wanted to use raw sql since I have trouble implementing the LEFT JOIN
with Hanami.
gem
?
Dry::Struct
.
Hi , I've ran this migration, which completed without errors, but when I run the server below:
Hanami::Model.migration do
change do
alter_table :segments do
add_column :ts_content1, :tsvector, generated_always_as: [to_tsvector: [:simple, :content]]
end
end
end
Error:
Hanami::Model::Error: missing attributes in ROM::Relation::Name(segments) schema: :ts_content1
How can I debug this?
Hi all. I am wondering if anyone has done/is doing application-level encryption à la Active Record Encryption https://guides.rubyonrails.org/active_record_encryption.html
I am looking to add most of the feature set of AR Encryption to our application.
Hi!
I'm having Content Security Policy problems with the Hanami 2 template project. Anyone here that could give a hint on what's wrong? :)
I'm trying to getting started with Hanami. We're hopefully going to use it in a new client project soon so we thought we should have a go and see if we can get it up and running.
I'm using a quite recent version of the Hanami 2 template https://github.com/hanami/hanami-2-application-template. I have a slightly different tool set than the one suggested in the readme. So I'm starting the project with the following:
./bin/install hello_hanami
yarn
yarn run start
# in another shell
bundle exec guard --no-notify --no-interactions
The asset server is up and running at localhost:8080. The application server is also up at port 3000 and displays correct content, but it doesn't load any assets. I get errors regarding the Content Security Policy:
Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at http://localhost:8080/assets/main/public.css (“default-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at http://localhost:8080/assets/main/public.js (“default-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at http://localhost:3000/favicon.ico (“default-src”).
I'm having some issues trying to utilize a params
block in an Action within hanami-2-application-template
. If I include the block, I receive an error: NoMethodError: undefined method 'params' for Main::Actions::Characters::New:Class
... digging into the code a bit, it appears that Hanami::Action:Validatable
, which includes the params(klass = nil, &blk)
definition, is only included in Hanami::Action::StandaloneAction
(which itself is included in Haname::Action
) if Validatable
is already defined: https://github.com/hanami/controller/blob/v2.0.0.alpha6/lib/hanami/action/standalone_action.rb#L55
...it seems to me I just need to add the correct gem to my Gemfile, or require the right library file (hanami/action/validatable
?) in the right source file, or something simple like that.
Any help?
I have a question about the Hanami.application
global. After digging through the code and testing it seems like this way of keeping a global reference to the app means that you can have only one Hanami instance running at once? So if I wanted to run two Hanami apps mounted at different paths in Sinatra, could I?
I'm not asking because I have that particular use case, but I am trying to solve some of the same problems that Hanami have solved and this is the final thing I'm stuck on. It might not be a problem for Hanami - normally you would just run a single instance anyway. But I'm building a REST API abstraction library and this global reference (if I understand it correctly) means that end users would not be able to have two API libraries based on my abstraction loaded at the same time - they would both try to use the global and get into a conflict, the same way you would if you tried to load two Hanami apps at once now.
Or am I missing something? :slight_smile: