Forum https://discourse.hanamirb.org – Code of Conduct http://hanamirb.org/community/#code-of-conduct
timriley on application-settings
Make container aware of lib loa… (compare)
timriley on application-settings
Allow settings to be nil It sh… Fix Syntax (compare)
timriley on application-settings
Add rough cut of settings suppo… Be more proactive loading doten… Remove unnecessary eval and 19 more (compare)
mereghost on update-dry-types
Update code for dry-types 1.2.2 (compare)
mereghost on update-dry-types
Update code for dry-types 1.2.2 (compare)
I suspect that the next version of hanami will sport a much better integration with the ROM/Dry universe since we closely collaborate with them.
Good to know !
Hiya, I’m trying out hanami (for fun) with the guides.
Take the download_count example:
https://guides.hanamirb.org/helpers/numbers/
If this was within the Web::Views::Books::Index context, what’s the hanami way to implement something like:
<% books.each do |book| %>
<p>book.download_count</p>
<% end %>
Which obviously doesn’t work, but download_count(book)
also feels wrong?
download_count(book)
.
SimpleDelegator
, Forwardable
, DelegateClass
, extending instances with a module, etc.). I therefore don't know if such a gem exists.
hi, i created a brand new hanami 1.3.3 app with hanami new
, everything default. then i generated a home#index action using hanami generate action web home#index
, and when i access that page I get this error https://i.imgur.com/44ilnqF.png (NameError at
uninitialized constant Hanami::View::Rendering::Scope::String
)
i've searched in google and github but i can't find anything about this error. does anyone know how to fix it? if this is not the right place to ask please direct me to the correct place, thank you!
Hello guys. How hanami handles routes with subdomains? I'm working on a project with a subdomain per client and I didn't figure out how to handle this using Hanami. In Rails I found some references:
# application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :ensure_subdomain
def current_blog
@current_blog ||= Blog.find_by(subdomain: request.subdomain)
end
helper_method :current_blog
private
def ensure_subdomain
redirect_to root_url(subdomain: :www) unless current_blog.present?
end
end
# routes.rb
Rails.application.routes.draw do
constraints(SubdomainRoutes) do
resources :blogs, only: [:new]
root 'welcome#index'
end
constraints(!SubdomainRoutes) do
resources :blogs, except: [:index, :new] do
resources :posts
end
root 'blogs#show'
end
end
# subdomain_routes.rb
class SubdomainRoutes
def self.matches? request
case request.subdomain
when '', 'www'
true
else
false
end
end
end
Source: https://www.driftingruby.com/episodes/working-with-subdomains
Hi, I’m trying to do some basic timezone stuff but my google-fu is failing me.
What I want to achieve:
3 & 4 works right out of the box, but I’m lost at 1 & 2. The closest thing I found was:
# config/initializers/sequel.rb
Sequel.application_timezone = :local
But everything is still saved as 2019-01-01 20:00:00 UTC. Timezones are hard :p
hanami-utils
v1.3.4 and hanami-view
v1.3.2 https://twitter.com/hanamirb/status/1177498984551612416
Well first of all, there is not ActiveSupport::TimeWithZone
equivalent in Hanami. So if you need complex time zone stuff - and basic Ruby is really lacking there - you'll need to pull in a Gem for that.tzinfo
has recently improved the interfaces/usability of it's classes, but I haven't checked that out yet. A couple years ago when I was working a lot with time zones I wrote my own gem because ActiveSupport::TimeWithZone
had some nasty bugs and while I liked the interface had many design decisions I did not like, plus it was difficult to get JUST time with zone and not all the rest.
I still regularly update that gem whenever there's a new tzinfo release, but I consider it "done". It focuses on correctness and ease of use over speed though.
But there is a gazillion other gems out there, any of which may do what you need. And if you don't have complex timezone needs, I'd suggest to stick with plain ruby as long as comfortably possible.
hanami db prepare