ruby

How to fix error requiring 'ibm_db' gem on Windows

痞子三分冷 提交于 2021-02-11 14:35:39
问题 I'm running Ruby 2.6.3p62 32-bit on Windows 10 64-bit. I installed it using the Ruby Installer. I successfully installed the gem 'ibm_db' without any errors. I downloaded the DB2-clidriver from http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/nt32_odbc_cli.zip, unzipped it an set the environment variable IBM_DB_HOME to its location. In addition, I added IBM_DB_HOME\bin to the PATH variable. When requiring the ibm_db I get the following error: C:\Users\myuser

Running bundle or rspec adds line to Gemfile.lock

孤人 提交于 2021-02-11 14:35:37
问题 After running various commands (bundle and rspec for example) in a Ruby project, Gemfile.lock is updated and x86_64-darwin-17 is added to the PLATFORMS heading. Why is this happening? How can I prevent it? Running gem env gives this interesting context: ○ → gem env RubyGems Environment: - RUBYGEMS VERSION: 2.7.6 - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin17] #...etc - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-17 回答1: This was caused by global bundler config. Setting to

Ruby to_xml with repeating same nodes

ⅰ亾dé卋堺 提交于 2021-02-11 14:35:34
问题 I would like to generate something like: <?xml version=\"1.0\" encoding=\"UTF-8\"?> <Test> <Car> <engine>A</engine> <wheels>4</wheels> </Car> <Car> <engine>B</engine> <wheels>2</wheels> </Car> </Test> but doing: {"Car"=>[{"engine"=>"A", "wheels"=>"4"}, {"engine"=>"B", "wheels"=>"2"}]}.to_xml(:root => "Test") returns: <?xml version=\"1.0\" encoding=\"UTF-8\"?> <Test> <Car type=\"array\"> <Car> <engine>A</engine> <wheels>4</wheels> </Car> <Car> <engine>B</engine> <wheels>2</wheels> </Car> </Car

Ruby on Rails not adding record to database

。_饼干妹妹 提交于 2021-02-11 14:32:22
问题 It's been a while since i dipped into Ruby on Rails and i'm having a hard time getting data into my model, here's what the server is saying when i submit my form: Processing ScoresController#index (for 127.0.0.1 at 2010-03-26 15:31:44) [POST] Parameters: {"commit"=>"Add", "authenticity_token"=>"326dd05ffa596bfa12ec3ebb6f48933dbad8dc0c", "score"=>{"name"=>"third score", "score"=>"4"}} Score Load (0.5ms) SELECT * FROM "scores" ORDER BY score DESC Rendering scores/index Completed in 5ms (View: 2

Why ruby controller would escape the parameters itself?

孤街醉人 提交于 2021-02-11 14:30:18
问题 I am writing Ruby application for the back end service. There is a controller which would accept request from front-end. Here is the case, there is a GET request with a parameter containing character "\n". def register begin request = { id: params[:key] } ......... end end The "key" parameter is passing from AngularJs as "----BEGIN----- \n abcd \n ----END---- \n", but in the Ruby controller the parameter became "----BEGIN----- \\n abcd \\n ----END---- \\n" actually. Anyone has a good solution

What do API and ABI versions mean in Ruby?

蹲街弑〆低调 提交于 2021-02-11 14:18:10
问题 I came across a comment in "Incorrect ruby version when specifying target path (--path) #5424", which I didn't understand: I believe since the API and ABI versions are 2.3.0, that's why that's used for the directory? In the same way rubygems install stuff for 1.9.3 in a directory called 1.9.1. Unless this is causing problems for your setup, I think it might be more of a curiousity than a bug For context, the Ruby version being discussed in the issue was 2.3.1. So apparently the "API and ABI

ruby / ability to share a single variable between multiple classes

丶灬走出姿态 提交于 2021-02-11 13:22:23
问题 For general classes manipulation understanding; given the following use case : class Child1 def process var 'child1' + var end end class Child2 def process var 'child1' + var end end class Child3 def process var 'child3' + var end end ... class Master attr_reader :var def initialize(var) @var = var end def process [ Child1.new.process(var), Child2.new.process(var), Child3.new.process(var) ] end end by some kind of inheritance or structure, would there be a way to have var available to all

ruby / ability to share a single variable between multiple classes

时间秒杀一切 提交于 2021-02-11 13:22:22
问题 For general classes manipulation understanding; given the following use case : class Child1 def process var 'child1' + var end end class Child2 def process var 'child1' + var end end class Child3 def process var 'child3' + var end end ... class Master attr_reader :var def initialize(var) @var = var end def process [ Child1.new.process(var), Child2.new.process(var), Child3.new.process(var) ] end end by some kind of inheritance or structure, would there be a way to have var available to all

ruby / ability to share a single variable between multiple classes

感情迁移 提交于 2021-02-11 13:22:09
问题 For general classes manipulation understanding; given the following use case : class Child1 def process var 'child1' + var end end class Child2 def process var 'child1' + var end end class Child3 def process var 'child3' + var end end ... class Master attr_reader :var def initialize(var) @var = var end def process [ Child1.new.process(var), Child2.new.process(var), Child3.new.process(var) ] end end by some kind of inheritance or structure, would there be a way to have var available to all

Check if two urls are for the same website

依然范特西╮ 提交于 2021-02-11 12:51:45
问题 I'm looking for a way to compare two urls. I can do: URI('http://www.test.com/blabla').host to have the base name, but this not reliable. For example: URI('http://www.test.com/blabla').host == URI('http://test.com/blabla').host returns false , but they can be the same site. To have the IP address is not reliable too because if I do: IPSocket.getaddress(URI('http://hello.herokuapp.com').host) == IPSocket.getaddress(URI('http://test.herokuapp.com').host) It returns true , but they are not the