Vito Botta
Joined
Activity
In case others need this, I found this gem, it can sort by array of ids with a native SQL query and return a relation.
Hi, @chris I am having this problem now trying to decide if to use ActiveStorage. If I go with your second option (I will have attachments in various places, and I think I will need sorting only in one case), what's the easiest/most efficient way of sorting the images by the given array of ids? Thanks!
Posted in Sorting Images using Active Storage
I'm also interested. Thanks in advance
Hi. I am trying to use Rails 6's automatic read/write splitting with the multiple databases feature. There seems to be a problem with Devise, because the automatic connection switching sends writes to the master for POST/PUT/DELETE requests and reads to the replicas for GET requests. However Devise makes changes/writes to the database even with GET requests sometimes (for example to confirm a user upon sign up using a token in the link in the confirmation email), so these changes are basically blocked by Rails. Does anyone have any idea for a workaround? I've opened a Github issue about it: https://github.com/plataformatec/devise/issues/5133
Thanks!
Nevermind. The redirection does work and the confusion came from the fact that Chrome/Brave/Safari hide the "www" part of the address. Not sure when this change was made. Firefox still shows the "www".
Uhm I just noticed using that puts command that the subdomain appears as "www" already so the redirection doesn't happen. But I am definitely visiting the website with the naked domain ?!
Hi, I am trying to force a redirect from naked domain to www from inside the Rails app, since I can't do this with the Nginx ingress in Kubernetes (basically, users can add custom domains and the app itself does some redirect depending on the domain etc, so long story short I cannot force the same redirect for all the requests using Nginx).
I am using a constraint to my routes.rb that checks if the request is for the naked domain, and if that's the case it redirect to the same path but with the www subdomain.
The constraint:
class Constraints::NakedDomain
def self.matches?(request)
puts request.subdomain
(request.host.downcase == Settings.domain) && (request.subdomain == "")
end
end
In routes.rb:
constraints(Constraints::NakedDomain) do
get ':any', to: redirect(subdomain: 'www', path: '/%{any}'), any: /.*/
end
I can see the www domain in the Network tab of the Dev tools in Chrome, but the domain in the address bar of the browser remains the naked domain. Is it because of Turbolinks? Does anyone know how to fix or anyway how to force redirection to www from inside Rails instead of the web server? Thanks!