ruby-2.0

cannot load such file — bundler/setup (LoadError)

ⅰ亾dé卋堺 提交于 2019-12-27 12:13:11
问题 I'm setting Rails 4 application with Ruby 2.0, but I'm getting "Web application could not be started" and get this trace: cannot load such file -- bundler/setup (LoadError) /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require' /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require' /usr/lib/ruby/gems/1.8/gems/passenger-4.0.19/lib/phusion_passenger/loader_shared_helpers.rb:212:in `run_load_path_setup_code' /usr/lib/ruby/gems/1.8

Confusion with singleton method defined on `Class` object

ε祈祈猫儿з 提交于 2019-12-24 12:38:26
问题 What I know singleton methods can be called by the objects, on which it is defined. Now in the below example C is also an object of Class and singleton method a_class_method defined on the Class object C . So how does another Class object D able to call a_class_method ? How does object individuation principle holds in this example? class C end #=> nil def C.a_class_method puts "Singleton method defined on #{self}" end #=> nil C.a_class_method #Singleton method defined on C #=> nil class D < C

Email subject not correctly assigned with Ruby net/smtp

萝らか妹 提交于 2019-12-24 10:54:46
问题 I use Ruby net/smtp require 'net/smtp' I send mails using the following method: Net::SMTP.start(SMTP_SERVER) do |smtp| smtp.send_message(message,"mailman-ruby@example.de",reciepent) end I want to add a subject to the mails i send but couldn't find one in the documentation. What I tried so far is putting the subject into the message like this: <<END_OF_MESSAGE Subject: test message . . . rest of the message END_OF_MESSAGE Unfortunally that doesnt do the trick! Anyone knows how to set subject

Overriden method still gets called

旧城冷巷雨未停 提交于 2019-12-23 15:37:42
问题 I am using a library that is implementing a belongs_to association between two entries in a database. Since this is not the behaviour I need I want to override this method via prepend . But pry tells me that the original method is still called. I double checked and I'm using ruby 2.0. The code that gets prepended: module Associations module ClassMethods [...] #Add the attributeName to the belongsToAttributes #and add a field in the list for the IDs def belongs_to(attr_name)

Ruby regexp handling of nbsp

♀尐吖头ヾ 提交于 2019-12-22 05:43:19
问题 In ruby 1.9.3 the regex engine doesn't treat nbsp's (\u00A0) as a space (\s). This is often a bummer for me. So my question is, will this change in 2.0? If not, is there any way to monkey patch a solution? 回答1: Use Unicode properties (you need to declare a matching source code encoding for this to work): # encoding=utf-8 if subject ~= /\p{Z}/ # subject contains whitespace or other separators or use POSIX character classes: if subject ~= /[[:space:]]/ According to the docs, \s will only match

Ruby 2.0.0 RVM fails compilation OS X 10.8.2 Mountain Lion

旧巷老猫 提交于 2019-12-21 12:09:20
问题 Trying to install it with RVM I get the following error: > [2013-02-25 10:09:24] make CC = /usr/local/bin/gcc-4.2 LD = ld > LDSHARED = /usr/local/bin/gcc-4.2 -dynamic -bundle CFLAGS = -O3 > -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -pipe XCFLAGS = -include

Rails 4.1 AWS Beanstalk cannot find secret key base

你。 提交于 2019-12-21 05:42:56
问题 I am trying to upload my rails project on AWS Beanstalk. I've already run eb init, eb start and configured the database settings to point to RDS. After I pushed using git aws.push and waited for AWS server to be started, the link provided says: "502 Bad Gateway nginx" In the logs ------------------------------------- /var/app/support/logs/passenger.log ------------------------------------- App 6861 stderr: [ 2014-05-29 13:26:59.1308 6893/0x00000001e50050(Worker 1) utils.rb:68 ]: *** Exception

Does multibyte character interfere with end-line character within a regex?

两盒软妹~` 提交于 2019-12-20 11:52:44
问题 With this regex: regex1 = /\z/ the following strings match: "hello" =~ regex1 # => 5 "こんにちは" =~ regex1 # => 5 but with these regexes: regex2 = /#$/?\z/ regex3 = /\n?\z/ they show difference: "hello" =~ regex2 # => 5 "hello" =~ regex3 # => 5 "こんにちは" =~ regex2 # => nil "こんにちは" =~ regex3 # => nil What is interfering? The string encoding is UTF-8, and the OS is Linux (i.e., $/ is "\n" ). Are the multibyte characters interfering with $/ ? How? 回答1: The problem you reported is definitely a bug of

Why was the object_id for true and nil changed in ruby2.0?

萝らか妹 提交于 2019-12-18 11:49:29
问题 I came across this ruby object_id allocation question sometime back and then read this awesome article which talks about VALUE and explains why object_id of true, nil and false the way they are. I have been toying with ruby2.0 object_id when I found the apparent change that has been made regarding object_id of true and nil. forbidden:~$ ruby -v ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux] forbidden:~$ forbidden:~$ irb irb(main):001:0> true.object_id => 20 irb(main):002:0> false

Rails - Get the time difference in hours, minutes and seconds

ε祈祈猫儿з 提交于 2019-12-18 03:03:15
问题 I'm looking for an idiomatic way to get the time passed since a given date in hours, minutes and seconds. If the given date is 2013-10-25 23:55:00 and the current date is 2013-10-27 20:55:09, the returning value should be 45:03:09. The time_difference and time_diff gems won't work with this requirement. 回答1: You can try with this: def time_diff(start_time, end_time) seconds_diff = (start_time - end_time).to_i.abs hours = seconds_diff / 3600 seconds_diff -= hours * 3600 minutes = seconds_diff