Stack Overflow » Ruby On Rails
75 FOLLOWERS
Stack Overflow is the largest, most trusted online community for developers to learn, share their programming knowledge, and build their careers. Here you can find out why does Rails sanitize() perform differently in rspec than in a model, how to update the Preferences Object in QBO and how to render code from db and make it work in erb file.
Stack Overflow » Ruby On Rails
22m ago
I have been banging my head on the desk on this for quite some time.
I have used the following guide to deploy my small Ruby on Rails application to a Digital Ocean droplet and run the app on a Nginx / Phusion passenger web server: https://gorails.com/deploy/ubuntu/22.04
Everything works fine up until I add the phusion passenger piece to the nginx config file. After I install nginx and start it. I can access my droplet IP and I see the "Welcome to Nginx screen"
Once I ass the phusion passenger bits and pieces to the server block for my app, when I try to reach my droplet IP, it just sits there ..read more
Stack Overflow » Ruby On Rails
2h ago
I am using grover gem to generate PDF from HTML template. Its working fine locally, but PDF looks UI less on production environment. I am using AWS cloudfront as CDN in production mode.
Here is a snippet of my code.
def download
file_export = file_exports.find_by_guid!(params[:id])
grover = Grover.new(file_export.data, format: 'A4')
send_data(grover.to_pdf,
filename: "#{file_export.sanitized_file_name}.pdf",
type: 'application/pdf')
end
Here file content is generated using.
file_content = action_controller.render_to_string(
template: 'performance/reviews ..read more
Stack Overflow » Ruby On Rails
2h ago
I have a gem which conditionally loads RailsWarden::Manager, based on a flag in the config/initializers/mygem.rb file:
module Mygem
class Railtie < Rails::Railtie
initializer "mygem_engine.initialize_warden" do |app|
if Mygem.use_warden_middleware?
app.config.middleware.use RailsWarden::Manager do |manager|
# Config for RailsWarden::Manager
end
end
end
end
end
This worked fine in some consumers, but in others the use_warden_middleware? gets called before the corresponding line in the config/initializers/mygem.rb gets loaded, to set the va ..read more
Stack Overflow » Ruby On Rails
4h ago
Trying to install ruby 2.5.3 on Mac M1 Chip, Got below error ..read more
Stack Overflow » Ruby On Rails
4h ago
Let's say I have a route /authors/:id, and its partial is lazily loading the author books in a table with a lazy loading turbo_frame_tag, via the route authors/:id/books, this table also have show, delete, update, routes for each table row to allow updating, deleting a book.
now everything works fine, but now users can access /authors/:id/books if they have typed the url and the other show, destroy, update routes. I don't want this page to be accessible outside of the author's show page, how can I restrict access to these pages if not in the context of author's show page ..read more
Stack Overflow » Ruby On Rails
4h ago
I have following set-up in AWS: ElasticLoadBalancer (SSL termination) -> EKS -> application_pod with Nginx and my app.
After load balancer there is http traffic and therefore I cannot force ssl in Rails application.
At load balancer we have http -> https redirect but it has to be turned off to target pentest finding. E.g. no way to keep this redirect.
We need to keep SSL termination at load balancer and have http traffic in EKS
When I generate a links using url_for(...), it automatically sets http://
Is there any way to configure UrlWriter to produce https:// links but don't force SSL ..read more
Stack Overflow » Ruby On Rails
5h ago
I am trying to set up a legacy rails repo that runs on Ruby 2.3.1, on my Macbook (M1 Pro, Mac OS Sonoma). Upon bundle install, I get this error about Nokogiri 1.7.1. Have tried a bunch of suggestions online but nothing has worked so far. Any idea how to fix this?
Tried the following
xcode-select --install - Says that the installed command line tools are already up to date
gem install nokogiri -v '1.7.1' --platform=ruby -- --use-system-libraries - Got the same error as above in the question
manually tried installing gem install nokogiri -v 1.7.1 --source 'https://rubygems.org/' but got the err ..read more
Stack Overflow » Ruby On Rails
5h ago
I have a gem which conditionally loads RailsWarden::Manager, based on a flag in the config/initializers/mygem.rb file:
module Mygem
class Railtie < Rails::Railtie
initializer "mygem_engine.initialize_warden" do |app|
if Mygem.use_warden_middleware?
app.config.middleware.use RailsWarden::Manager do |manager|
# Config for RailsWarden::Manager
end
end
end
end
end
This worked fine in some consumers, but in others the use_warden_middleware? gets called before the corresponding line in the config/initializers/mygem.rb gets loaded, to set the va ..read more
Stack Overflow » Ruby On Rails
7h ago
I'm trying to get watermarked image by sending get request from next.js front-end as follows: Here I'm sending event_image id so that I can access it in back-end and apply watermark to it then return to front-end `const handleImageDownload = async (eventImageId) => { try { const response = await getWatermarkedImageApi(eventImageId);
if (response.status !== 200) {
throw new Error('Failed to watermark image');
}
const data = response.data;
console.log(data);
} catch (error) {
setError(error.message);
} finally {
setLoading(false);
}
}`
Now coming to rails back-end in event_i ..read more
Stack Overflow » Ruby On Rails
10h ago
I am new to react native and I want to create a mobile version of the the project I made in Ruby on Rails. One part there is in my RoR project it's easy to generate and download a pdf file. I want also want to do it in a Mobile App. But well it's not working I've been asking a lot of question to my github co-pilot and chatgpt for answers but I can't still figure it out.
I tested the RoR side since I am much familiar in that side and It generates the pdf file as expected the problem is the mobile app. Whenever I press the button it says it's successfully downloaded the file but I got prompt or ..read more