ruby-1.9.3

How to set SameSite attribute to 'None; Secure' in Rails3.1.12 and Ruby1.9.3

可紊 提交于 2020-04-07 04:13:12
问题 A cookie associated with a cross-site resource at https://example.com/ was set without the SameSite attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with SameSite=None and Secure . You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032. Please let me know how to set the SameSite

Does requiring a gem load everything, including things I don't use?

一笑奈何 提交于 2020-02-02 11:45:45
问题 Assume x is a gem, that contains both Hello and Goodbye classes. If I write a program that require 'x' , but only uses the Hello class. Is the Goodbye class loaded as well? 回答1: You include scripts or files, not gems. With require 'x' you load the file x.rb . Which x.rb you load is defined by the search path, the search pathes can be modified by gem definitions (what you didn't use in your example code). Everything inside the file x.rb is loaded. If x.rb contains other require commands, those

How “puts” statement works in Ruby?

夙愿已清 提交于 2020-01-25 23:19:35
问题 I knew that puts return always nil by itself. But knowing that fact already I have started to play around it. here it is: >> puts => nil # Good, you are doing what I expected. >> puts 15 15 => nil # nil is for puts and 15 it printed,as it is assigned to do. perfect still. >> puts a = 5 + 2 7 => nil # still good. Now I will do a bit more with puts to see how robust it is. >> puts a= 5 + 2;b= 2+3 7 => 5 #ahh! where is nil? >> puts a= 5 + 2;b= 2+3;c= 4+8 7 => 12 # again no nil. Another confusion

Matching position in gsub or scan

痴心易碎 提交于 2020-01-23 09:48:33
问题 What is the best way to achieve the matching position (the index that would be returned by =~ ) for each match when using gsub or scan ? 回答1: "hello".gsub(/./) { Regexp.last_match.offset(0).first } => "01234" See Regexp.last_match and MatchData. 回答2: I came to this problem from a different direction, and could not come up with a decent solution (that is, understandable, maintainable) to do this with either gsub or scan (both built-in methods of String class). So I asked "Why do it this way?..

Matching position in gsub or scan

痞子三分冷 提交于 2020-01-23 09:47:27
问题 What is the best way to achieve the matching position (the index that would be returned by =~ ) for each match when using gsub or scan ? 回答1: "hello".gsub(/./) { Regexp.last_match.offset(0).first } => "01234" See Regexp.last_match and MatchData. 回答2: I came to this problem from a different direction, and could not come up with a decent solution (that is, understandable, maintainable) to do this with either gsub or scan (both built-in methods of String class). So I asked "Why do it this way?..

Installing RVM/Ruby 1.9.3 via Chef

笑着哭i 提交于 2020-01-17 07:40:12
问题 I'm just getting started with trying to move my infrastructure over to Chef, and I think I must be missing something obvious. I'm using the chef-rvm cookbook to install RVM, and I'd like it to install Ruby 1.9.3p125 and set that as the default. Here's my base server role: name "base" description "Basic configuration for all nodes" run_list( 'recipe[git]', 'recipe[sudo]', 'recipe[ubuntu]', 'recipe[rvm]', 'recipe[postgresql::client]' ) override_attributes( :authorization => { :sudo => { :users

A method that applies self to a proc

落花浮王杯 提交于 2020-01-16 11:48:23
问题 I want to have a method defined on Object that takes a block and applies the receiver to the block. An implementation will be like the following: class Object def apply ≺ pr.call(self) end end 2.apply{|x| x * 3} # => 6 Is there already a standard way to do this or a well known library that has a method with similar use? If so, I didn't want to reinvent the wheel. It happens to me very often that, I have a method that takes an optional block, and when there is no block, I want to return

Debug Not Working After Upgrade To Ruby 1.9.3 And Rails 3.2.2

◇◆丶佛笑我妖孽 提交于 2020-01-15 11:36:49
问题 I have upgraded my app to use Ruby 1.9.3p0 and Rails 3.2.2. To get bundler working I changed this: gem 'ruby-debug' to this: gem 'ruby-debug19' Now rails server gives: Could not find archive-tar-minitar-0.5.2 in any of the sources Run `bundle install` to install missing gems. Running bundle install does not help. The error goes away when I remove ruby-debug19 gem from my Gemfile, but then debugging does away too. I also tried changing the Gemfile to: gem 'ruby-debug19', :require => 'ruby

Debug Not Working After Upgrade To Ruby 1.9.3 And Rails 3.2.2

前提是你 提交于 2020-01-15 11:33:10
问题 I have upgraded my app to use Ruby 1.9.3p0 and Rails 3.2.2. To get bundler working I changed this: gem 'ruby-debug' to this: gem 'ruby-debug19' Now rails server gives: Could not find archive-tar-minitar-0.5.2 in any of the sources Run `bundle install` to install missing gems. Running bundle install does not help. The error goes away when I remove ruby-debug19 gem from my Gemfile, but then debugging does away too. I also tried changing the Gemfile to: gem 'ruby-debug19', :require => 'ruby

Installing ruby-debug-base19 on Windows in Ruby 1.9.3

北城以北 提交于 2020-01-13 09:08:31
问题 I need to install ruby-debug-base19 in order to active debug on Netbeans IDE, when I execute: $ gem install ruby-debug-base19 I got the following error. Extracted from log generate C:/Ruby193/bin/ruby.exe extconf.rb checking for rb_method_entry_t.body in method.h... no checking for vm_core.h... no C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39: Use RbConfig instead of obsolete and deprecated Config. checking for rb_method_entry_t.body in method.h... no