草庐IT

load-store-functions

全部标签

ruby-on-rails - 尝试在测试中运行 rails c 时获取 config.eager_load 设置为 nil

我正在尝试运行Rails(4.1.2)控制台railscRAILS_ENV=test我得到这个:>config.eager_loadissettonil.Pleaseupdateyour>config/environments/*.rbfilesaccordingly:>>*development-setittofalse*test-setittofalse(unless>youuseatoolthatpreloadsyourtestenvironment)*production->setittotrue>>/Users/xxxxxx/.rvm/gems/ruby-2.2.2/gems

ruby-on-rails - bcrypt 加载错误 : Cannot load such file

我正在尝试为我的Rails应用程序设置登录功能,当我按下登录按钮时,我收到一条bcrypt错误消息:LoadErrorinSessionsController#createcannotloadsuchfile--bcrypt还有其他人遇到这个错误吗?我有最新版本的bcrypt,我完全按照教程告诉我的去做。用户模型:我在据称错误所在的行周围加上了星号。classUsersessionController:classSessionsController应用程序Controller:classApplicationControllersession助手:moduleSessionsHelpe

ruby - "RVM is not a function"错误

RVM已正确安装在我的机器上(运行MacOSX10.6.8)并且运行良好。奇怪的是,要运行它,我必须为每个新session使用source~/.rvm/scripts/rvm。我尝试从它创建一个符号链接(symboliclink)到/opt/local/bin/rvm,但是当它运行时它什么也不做。我还尝试创建一个从~/.rvm/bin/rvm到/opt/local/bin/rvm的符号链接(symboliclink),当我运行rvm在终端中,它会按预期显示帮助页面。但是当我尝试rvmusesome_ruby_version时,它总是显示“RVM不是一个函数,选择带有‘rvmuse...

ruby - "extend self"与 "module_function"相同吗?

extendself和module_function是实现它的两种ruby​​方法,因此您可以在模块上调用方法,如果包含该模块也可以调用它。这些方式的最终结果有什么不同吗? 最佳答案 module_function将给定的实例方法设为私有(private),然后复制并将它们作为公共(public)方法放入模块的元类中。extendself将所有实例方法添加到模块的单例中,保持它们的可见性不变。moduleMextendselfdefa;endprivatedefb;endendmoduleNdefc;endprivatedefd;e

ruby-on-rails - Rails 错误 "cannot load such file -- less"

我是rubyonrails的新手,我一直在尝试使用twitter-bootstrap作为Assets,所以我将它包含在我的Gemfile中,捆绑并它安装成功。但是我注意到它依赖于某些在我执行“捆绑”命令时未显示的依赖项。它需要的依赖(1)Libv8(2)Less(3)Less-rails错误信息:cannotloadsuchfile--less(inc:/Sites/todo/app/assets/stylesheets/bootstrap_and_overrides.css.less)[code]Extractedsource(aroundline#8):5:6:7:8:"all"%

ruby - 我如何从 `require' : no such file to load in ruby? 中拯救

我正在尝试从“require”中解救出来:没有这样的文件可以按顺序加载到ruby​​中提示用户指定-I标志,以防他忘记这样做。基本上代码如下所示:beginrequire'someFile.rb'rescueputs"someFile.rbwasnotfound,haveyou"puts"forgottentospecifythe-Iflag?"exitend我原以为rescue部分会在找不到someFile.rb的情况下接管执行,但我的假设是错误的。 最佳答案 没有参数的rescue只拯救StandardErrors。LoadEr

ruby-on-rails - ruby 2.0 rails gem 安装错误 "cannot load such file -- openssl"

我正在使用osx10.8.2安装了ruby2.0并且....尝试运行"sudogeminstallrails"时得到这个$sudogeminstallrailsERROR:Loadingcommand:install(LoadError)cannotloadsuchfile--opensslERROR:Whileexecutinggem...(NoMethodError)undefinedmethod`invoke_with_build_args'fornil:NilClass我之前使用ruby​​1.9.x和rails3.2.x工作正常 最佳答案

ruby-on-rails - rails : I can't call a function in a module in/lib - what am I doing wrong?

我有一个模块保存在/lib中作为test_functions.rb看起来像这样moduleTestFunctionsdefabcputs123endend进入ruby​​脚本/运行程序,我可以看到该模块正在自动加载(良好的配置约定等等......)>>TestFunctions.instance_methods=>["abc"]所以方法是已知的,让我们尝试调用它>>TestFunctions.abcNoMethodError:undefinedmethod`abc'forTestFunctions:Modulefrom(irb):3没有。这个怎么样?>>TestFunctions::a

ruby module_function 与包含模块

在ruby​​中,我知道可以使用module_function在模块中混合使用模块函数,如此处所示。我知道这是多么有用,因此您可以在不混入模块的情况下使用该函数。moduleMyModuledefdo_somethingputs"helloworld"endmodule_function:do_somethingend我的问题是为什么您可能希望以这两种方式定义函数。为什么不拥有defMyModule.do_something或defdo_something在什么样的情况下,将函数混入或用作静态方法会有用? 最佳答案 想到Enumer

ruby-on-rails - Rails 安装在 Ubuntu 上失败,错误为 "cannot load such file -- mkmf"

我在Ubuntu11上安装Rails时遇到了这个问题:root@salah:/home/salah/rubygems-1.8.15#sudogeminstallmysqlFetching:mysql-2.8.1.gem(100%)Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingmysql:ERROR:Failedtobuildgemnativeextension./usr/bin/ruby1.9.1extconf.rb/usr/local/lib/site_ruby/1.9.1/rubygems/c