Unable to install gem – Failed to build gem native extension – cannot load such file — mkmf (LoadError)

There are similar questions: `require’: no such file to load — mkmf (LoadError) Failed to build gem native extension (mkmf (LoadError)) – Ubuntu 12.04 Usually, the solution is: sudo apt-get install ruby-dev Or, if that doesn’t work, depending on your ruby version, run something like: sudo apt-get install ruby1.9.1-dev Should fix your problem. Still not … Read more

What does << mean in Ruby?

It can have 3 distinct meanings: ‘<<‘ as an ordinary method In most cases ‘<<‘ is a method defined like the rest of them, in your case it means “add to the end of this array” (see also here). That’s in your particular case, but there are also a lot of other occasions where you’ll encounter … Read more

ruby operator “=~” [duplicate]

The =~ operator matches the regular expression against a string, and it returns either the offset of the match from the string if it is found, otherwise nil. You can place the string/regex on either side of the operator as you can see above.

class << self idiom in Ruby

First, the class << foo syntax opens up foo‘s singleton class (eigenclass). This allows you to specialise the behaviour of methods called on that specific object. Now, to answer the question: class << self opens up self‘s singleton class, so that methods can be redefined for the current self object (which inside a class or module body is the class or module itself). Usually, … Read more

How to use “gets” and “gets.chomp” in Ruby

gets lets the user input a line and returns it as a value to your program. This value includes the trailing line break. If you then call chomp on that value, this line break is cut off. So no, what you have there is incorrect, it should rather be: gets gets a line of text, including a line break at the end. … Read more

What does %w(array) mean?

%w(foo bar) is a shortcut for [“foo”, “bar”]. Meaning it’s a notation to write an array of strings separated by spaces instead of commas and without quotes around them. You can find a list of ways of writing literals in zenspider’s quickref.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)