我刚刚将.rubocop.yml文件添加到我的项目中,并将其添加到.gitignore文件中,但是当我这样做时,git status它显示为已修改。我从未将此文件添加到我的存储库。为什么.gitignore不忽略此文件?
应用程序/配置/.rubocop.yml
.rubocop.yml
其他文件也可以忽略,例如,我还尝试将tags文件添加到项目的根目录并将其添加到.gitignore,并且可以正常工作。
为什么.gitignore不忽略.rubocop.yml文件?
我在后台作业中为发票生成了一个 PDF 文件,我想将其附加到发票中。我使用 Carrierwave 进行文件上传,但在这里我不从 UI 上传它。我希望能够附加文件而不将其保存在磁盘上。
发票.rb
mount_uploader :file, InvoiceFileUploader
Run Code Online (Sandbox Code Playgroud)
后台工作
class GeneratePdfJob < ApplicationJob
queue_as :default
def perform(invoice)
pdf = InvoiceServices::PdfGenerator.new(invoice)
file_name = [invoice.number.gsub('/','-'), invoice.due_date.to_s, SecureRandom.urlsafe_base64].join('-') + '.pdf'
pdf.render_file(file_name)
file = File.new(file_name)
invoice.file = file
File.delete(file_name)
end
end
Run Code Online (Sandbox Code Playgroud)
所以现在我调用render_file方法来实际创建文件,但是这个文件被保存在我的应用程序的根文件夹中,所以我需要在之后删除它。有没有更好的办法?有没有办法附加文件而不实际将其保存在磁盘上?
我需要帮助使用 Faraday gem 来存根请求。我正在提出这个请求
URL='https://secure.snd.payu.com//pl/standard/user/oauth/authorize'.freeze
url_encoded = 'grant_type=client_credentials' \
+ "&client_id=#{ENV['client_id'}" \
+ "&client_secret=#{ENV['client_secret'}"
connection = Faraday.new do |con|
con.response :oj, content_type: /\bjson$/
con.adapter Faraday.default_adapter
end
connection.post(URL, url_encoded)
Run Code Online (Sandbox Code Playgroud)
哪个输出
#<Faraday::Response:0x00000000016ff620 @on_complete_callbacks=[], @env=#<Faraday::Env @method=:post @body={"access_token"=>"00a4e007-220b-4119-aae8-3cb93bb36066", "token_type"=>"bearer", "expires_in"=>43199, "grant_type"=>"client_credentials"} @url=#<URI::HTTPS https://secure.snd.payu.com/pl/standard/user/oauth/authorize> @request=#<Faraday::RequestOptions (empty)> @request_headers={"User-Agent"=>"Faraday v0.17.1"} @ssl=#<Faraday::SSLOptions verify=true> @response=#<Faraday::Response:0x00000000016ff620 ...> @response_headers={"set-cookie"=>"cookieFingerprint=70a4a8d1-7b05-4cb9-9d5c-5ad12e966586; Expires=Fri, 25-Dec-2020 09:31:02 GMT; Path=/; ; HttpOnly, payu_persistent=mobile_agent-false#; Expires=Sun, 20-Dec-2020 09:31:02 GMT; Path=/; ; HttpOnly", "correlation-id"=>"0A4DC804-62FD_AC11000F-0050_5E047DD5_8A0178-0015", "cache-control"=>"no-store, no-cache, no-store, must-revalidate", "pragma"=>"no-cache, no-cache", "content-type"=>"application/json;charset=UTF-8", "transfer-encoding"=>"chunked", "date"=>"Thu, 26 Dec 2019 09:31:01 GMT", "server"=>"Apache", "x-content-type-options"=>"nosniff", …Run Code Online (Sandbox Code Playgroud) 我如何从中得到:
hello world
hello world
hello world
hello world
Run Code Online (Sandbox Code Playgroud)
对此:
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
Run Code Online (Sandbox Code Playgroud)
使用vim-surround或vim-emmet.
当我突出显示文本时,按ctrl + y然后按','我可以键入p标签,但它包围一个p标签中的所有4个段落.