ruby

Stop images from caching in Rails and browser?

大兔子大兔子 提交于 2021-02-07 08:22:35
问题 I have created a image crop facility that I can click on an image and crop it and it saves the new cropped image over the old one, then redirects back to the original page where the image was show. But it still shows the old image even after a redirect and doesn't display the new one till I refresh the page. I have tried just using an image tag and removing the asset timestamp after the image but it still displays the old image and I have also tried adding meta tags to stop browser caching

Rendering a Rails view from within a Sidekiq Worker

我是研究僧i 提交于 2021-02-07 08:22:23
问题 I have a Sidekiq worker that does some background processing and then finally POSTs a success message to a 3rd party API. This message I post is essentially a "thank you" message and can contain HTML. In the message I'd like to link back to my site in a properly formatted way. This naturally sounds like a view to me. I'd love to simply use a view template, render it to HTML and finally post it off to the API. For the life of me, i cannot figure how to render a view from within my Sidekiq

Rendering a Rails view from within a Sidekiq Worker

痴心易碎 提交于 2021-02-07 08:20:35
问题 I have a Sidekiq worker that does some background processing and then finally POSTs a success message to a 3rd party API. This message I post is essentially a "thank you" message and can contain HTML. In the message I'd like to link back to my site in a properly formatted way. This naturally sounds like a view to me. I'd love to simply use a view template, render it to HTML and finally post it off to the API. For the life of me, i cannot figure how to render a view from within my Sidekiq

rails 4 not using digests in asset filenames, but only in production

和自甴很熟 提交于 2021-02-07 08:01:41
问题 The bounty expires in 2 days . Answers to this question are eligible for a +100 reputation bounty. stevec wants to draw more attention to this question: I have a similar problem (albeit slightly less complicated) here: stackoverflow.com/questions/65990841/… Basically assets aren't being given their full url (with digest) in production, so they simply aren't working. The urls are generated in the controller, and image_url() doesn't seem to return the same result from the controller as it does

Create a method like Devise's current_user to use everywhere

旧时模样 提交于 2021-02-07 07:53:40
问题 I'm allowing my users to have multiple profiles (user has many profiles) and one of them is the default. In my users table I have a default_profile_id. How do I create a "default_profile" like Devise's current_user which I can use everywhere? Where should I put this line? default_profile = Profile.find(current_user.default_profile_id) 回答1: Devise's current_user method looks like this: def current_#{mapping} @current_#{mapping} ||= warden.authenticate(:scope => :#{mapping}) end As you can see,

Install ruby gems offline / proxy configuration

醉酒当歌 提交于 2021-02-07 07:34:18
问题 I need to install ruby on rails + Nokogiri, httparty, json [and some less significant gems] on server which does not have connection to internet. How it could be done? host operating system is windows Additional question, well, it is not very good for me, since it can takes some days, but I can as customer to give this server access to the http proxy. However I must confess, that I already tried to use somethin like that set http_proxy="http://username:password@host:port" or gem --http_proxy

Garbage collector in Ruby on Rails?

元气小坏坏 提交于 2021-02-07 07:10:21
问题 I have tried to Google a lot about Rails Garbage collector, but I didn't get a reliable answer. Has anyone got a source to show how garbage collection is implemented in Rails? How can we control it? 回答1: Rails is a framework, not a language. The language behind Rails is called Ruby. This means there is no notion of Garbage Collector in Rails. You should search for documentation about the Ruby Garbage Collector. You can start from the Ruby GC module. The GC module provides an interface to Ruby

Garbage collector in Ruby on Rails?

丶灬走出姿态 提交于 2021-02-07 07:07:02
问题 I have tried to Google a lot about Rails Garbage collector, but I didn't get a reliable answer. Has anyone got a source to show how garbage collection is implemented in Rails? How can we control it? 回答1: Rails is a framework, not a language. The language behind Rails is called Ruby. This means there is no notion of Garbage Collector in Rails. You should search for documentation about the Ruby Garbage Collector. You can start from the Ruby GC module. The GC module provides an interface to Ruby

Webpacker::Manifest::MissingEntryError in Hello#index ( ruby on rails)

谁说胖子不能爱 提交于 2021-02-07 06:24:15
问题 I have downloaded the Honeybadger webpack example and run bundle install . I don't have any errors in terminal, yet get the following when I start my server: Webpacker can't find application.js in /Users/admin/Documents/sourcemap/honeybadger-rails-webpacker-example/public/packs/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. Webpack has not yet re-run to reflect

Webpacker::Manifest::MissingEntryError in Hello#index ( ruby on rails)

故事扮演 提交于 2021-02-07 06:23:19
问题 I have downloaded the Honeybadger webpack example and run bundle install . I don't have any errors in terminal, yet get the following when I start my server: Webpacker can't find application.js in /Users/admin/Documents/sourcemap/honeybadger-rails-webpacker-example/public/packs/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. Webpack has not yet re-run to reflect