ruby

Download asset file from asset in Azure media service

痴心易碎 提交于 2021-01-28 06:43:13
问题 I have an issue. I have an asset in the azure media service. The asset contains an asset file. I would like to know how to download the asset file. I'm using httparty gem for this. HTTParty.get(https://<host>.restv2.<location>.media.azure.net/api/Files('<file_id>'), headers: headers) The headers have the authorization value. The above request gives the metadata of the asset file but I would like to download the asset file. Can anyone please help. Thanks. I have gone through the below

Get Two Rails apps to share the same Redis data

亡梦爱人 提交于 2021-01-28 05:36:36
问题 I have two rails apps. The first app constantly calculates some data and stores it in Redis (This app is running on JRuby 1.7.4 and Rails 4). The second app reads this data from the same Redis server (This app is running on Ruby 2.0.0 and Rails 4). After trying to achieve this configuration in my local development environment, it's apparent that my Redis data is not being shared between the two apps. In both apps, my config/initializers/redis.rb file looks like this: uri = URI.parse(ENV[

Problems upgrading Rails 4.0.0 to 4.0.x (4.0.13) - private method `include' called for ActionDispatch::Assertions:Module (NoMethodError)

試著忘記壹切 提交于 2021-01-28 05:11:13
问题 I could not find a "direct" answer to this anywhere. Since I know there will be many other "Late Upgraders" to the party, I feel I need to get this out. I had a Rails 4.0.0 app running Ruby 2.0.0-p247. After upgrading to 4.0.13, I ran into this error: private method `include' called for ActionDispatch::Assertions:Module (NoMethodError) I received this through rspec and WEBrick. 回答1: I found a solution via another issue from layer-ruby: NoMethodError: private method `include' called for #

Unable to use OptionParser and rspec

和自甴很熟 提交于 2021-01-28 05:08:13
问题 I have a simple watir (web-driver) script which goes to google. But, I want to use option parser to set an argument in the cmd to select a browser. Below is my script: require 'optparse' require 'commandline/optionparser' include CommandLine require 'watir-webdriver' describe 'Test google website' do before :all do options = {} opts = OptionParser.new do |opts| opts.on("--browser N", "Browser to execute test scripts") do |n| options[:browser] = n $b = n.to_s end end opts.parse! ARGV p options

Job failed to load: uninitialized constant with Delayed Job and Rails 3

 ̄綄美尐妖づ 提交于 2021-01-28 04:52:52
问题 I'm trying to utilize Delayed Job in my Rails 3 app, but keep hitting a snag. The jobs keep failing with the error: Job failed to load: uninitialized constant CrawlJob. I found a couple of other SO threads and followed advice there to no avail. Here is the relevant code. Application.rb require File.expand_path('../boot', __FILE__) require 'rails/all' ... module Decurate class Application < Rails::Application ... config.autoload_paths += %W(#{config.root}/lib) config.autoload_paths += Dir["#

Rails Rspec controller testing with nested resources

岁酱吖の 提交于 2021-01-28 04:48:44
问题 I have nested resources: resources :requests do resources :responses end and want to write controller test for response model. When I try to write: RSpec.describe ResponsesController, type: :controller do describe 'GET #show' do before do @testrequest = Request.create @testresponse = @testrequest.responses.create get :show, request_id: @testrequest.id, id: @testresponse.id end it 'show specific response selected by id if user owner of response or user owner of parent request' do expect

Ruby - parsing JSON coming via URL

久未见 提交于 2021-01-28 04:32:20
问题 I'm sending a JSON object to ruby with javascript. But I cannot parse it in there. I tried following stuff but no luck. Also I've been searching around for while now, but I couldn't find anything helpful. Note that I'm very new ruby. My trials: def initialize(game_conf_json) parsed_conf = JSON.parse(conf_json) @param1 = parsed_conf['name'][0] @param2 = parsed_conf['surname'][0] =begin I also tried this: @param1 = parsed_conf['name'] @param2 = parsed_conf['surname'] But no matter what other

How to fix “dyld: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib” permanently for Ruby?

旧城冷巷雨未停 提交于 2021-01-28 03:14:10
问题 I updated my OS about 2 weeks ago, and since then I've been running into this issue: > ruby -v dyld: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib Referenced from: /Users/me/.rvm/rubies/ruby-2.2.1/bin/ruby Reason: image not found [1] 65487 trace trap ruby -v A solution found here (Ruby -v dyld: Library not loaded: /usr/local/lib/libgmp.10.dylib) works for each terminal session, but not permanently. I am running OS 10.9.5. This is what works temporarily: rvm reinstall 2.1.4 This

Rails Custom Delayed Job - uninitialized constant

梦想与她 提交于 2021-01-28 03:12:36
问题 I've been successfully using delayed_job for a couple of years now but recently I have a need to implement some kind of success/failure callback/hooks. Following the delayed_job guide on github i've set up the following custom job: class XmlImportJob < Struct.new(:file, :supplier_id, :user_id, :directory) def perform Product.xml_import(file, supplier_id, user, directory) end def success(job) ProductMailer.xml_import_complete.deliver end def failure(job) ProductMailer.xml_import_failed.deliver

When not to use to_sym in Ruby?

对着背影说爱祢 提交于 2021-01-28 03:09:28
问题 I have a large dataset from an analytics provider. It arrives in JSON and I parse it into a hash, but due to the size of the set I'm ballooning to over a gig in memory usage. Almost everything starts as strings (a few values are numerical), and while of course the keys are duplicated many times, many of the values are repeated as well. So I was thinking, why not symbolize all the (non-numerical) values, as well? I've found some discusion of potential problems, but I figure it would be nice to