相关疑难解决方法(0)

安装调试器时出错(1.6.6)

当我运行bundle install时,我在安装调试器gem(1.6.6)时遇到错误.我正在使用ruby 2.1.1和rails 4.0.4.我对rails很新,不知道是什么导致了这个问题.

的Gemfile

错误

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb 
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
Makefile creation failed
*************************************************************

NOTE: If your headers were not found, try passing
    --with-ruby-include=PATH_TO_HEADERS      

*************************************************************

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably …
Run Code Online (Sandbox Code Playgroud)

ruby gem ruby-on-rails rvm

2
推荐指数
1
解决办法
6336
查看次数

Ruby初学者课题

在我开始使用rails dev之前,我正在尝试更深入地学习ruby,但是我在学习课程时遇到了一些问题.我似乎无法理解为什么以下不起作用.

#point.rb
class Point
  attr_accessor :x, :y

  def initialize(p = [0,0])
   @x = p[0]
   @y = p[1]
  end
end

#shape.rb
require_relative 'point.rb'

class Shape

  attr_accessor :points

  def initialize *the_points
    for p in the_points
      @points.append Point.new(p)
    end
  end

end

s = Shape.new([3,2])

puts s.points
Run Code Online (Sandbox Code Playgroud)

当我调用该函数时,我得到NilClass的no方法错误,我假设它是指@ point.append.

ruby class

0
推荐指数
1
解决办法
911
查看次数

为什么三个点写入新行?

puts "Hello! Reading temperature value from data file..."
num = File.read("temp.dat")
puts "The number is #{num}..."
celsius = num.to_i
fahrenheit = (celsius.to_i * 9 / 5) + 32
puts "The Fahrenheit value is: #{ fahrenheit }."
Run Code Online (Sandbox Code Playgroud)

在第三行中,块...之后#{num}以新行打印.我的印象是使用该块将参数传递给显示器,以便更容易格式化.

为什么点到了新的一行?

ruby string format

0
推荐指数
1
解决办法
187
查看次数

为什么Ruby连接而不是添加2个值?

我写了一个小程序来测试Textmate 2(我对Ruby很新),并且由于某些原因它正在吐出4 + 9 = 49而不是13.

def add(x,y)
  c = x + y
  return c
end

puts "please enter a value "
a = gets.chomp
puts "please enter another value "
b = gets.chomp

printMe = add(a,b)

puts printMe
Run Code Online (Sandbox Code Playgroud)

ruby concatenation add

0
推荐指数
1
解决办法
752
查看次数

标签 统计

ruby ×4

add ×1

class ×1

concatenation ×1

format ×1

gem ×1

ruby-on-rails ×1

rvm ×1

string ×1