草庐IT

required_without_all

全部标签

ruby - 在 Mac 10.7 上运行 'requirements_osx_brew_libs_install...' 时出错

尝试在上一代MacbookPro上安装brew并不断收到以下错误:Errorrunning'requirements_osx_brew_libs_installautoconfautomakelibtoolpkg-configapple-gcc42libyamlreadlinelibxml2libxsltlibksbaopensslsqlite',pleaseread/Users/allegrascrugham/.rvm/log/ruby-1.9.3-p392/1368142352_package_install_autoconf_automake_libtool_pkg-config

ruby-on-rails - rails : Postgres permission denied to create database on rake db:create:all

我正在尝试创建用于开发和测试的postgres数据库。我正在使用:OSX优胜美地Rails版本:4.2.0git版本:2.2.2psql版本:9.4.0ruby版本:2.1.0p0自制软件版本:0.9.5gem文件:gem'pg'数据库.yml:default:&defaultadapter:postgresqlencoding:unicodepool:5development:rakedb:create:all返回PG::InsufficientPrivilege:ERROR:permissiondeniedtocreatedatabase:CREATEDATABASE"myapp_

ruby-on-rails - Rails 路线 : GET without param :id

我正在开发基于Rails的RESTAPI。要使用此API,您必须登录。关于这一点,我想在我的用户Controller中创建一个方法me,它将返回已登录用户信息的JSON。因此,我不需要在URL中传递:id。我只想调用http://example.com/api/users/me所以我尝试了这个:namespace:api,defaults:{format:'json'}doscopemodule::v1,constraints:ApiConstraints.new(version:1,default:true)doresources:tokens,:only=>[:create,:de

ruby - 安装 RVM : "Requirements installation failed with status: 1."

这是我在命令提示符之前看到的最后一件事:Searchingforbinaryrubies,thismighttakesometime.Foundremotefilehttps://rvm.io/binaries/osx/10.9/x86_64/ruby-2.1.1.tar.bz2Checkingrequirementsforosx.AbouttoinstallHomebrew,press`Enter`fordefaultinstallationin`/usr/local`,typenewpathifyouwishcustomHomebrewinstallation(thepathnee

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 - 什么是 Post.all.map(& :id) mean?

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Whatdoesmap(&:name)meaninRuby?Post.all.map(&:id)会回来=>[1,2,3,4,5,6,7,................]map(&:id)是什么意思?特别是&。

ruby-on-rails - 测试 : how to focus on behavior instead of implementation without losing speed?

似乎有两种完全不同的测试方法,我想引用它们。问题是,这些意见是在5年前(2007年)提出的,我很感兴趣,从那以后发生了什么变化,我应该走哪条路。BrandonKeepers:Thetheoryisthattestsaresupposedtobeagnosticoftheimplementation.Thisleadstolessbrittletestsandactuallyteststheoutcome(orbehavior).WithRSpec,Ifeellikethecommonapproachofcompletelymockingyourmodelstotestyourcontr

ruby - Ruby 'require' 语句是在类定义内部还是外部?

在Ruby中使用类文件时,您是将“requires”语句放在文件的顶部,还是放在类定义中? 最佳答案 从技术上讲,这并不重要。require只是一个普通的方法调用,它被调用的范围不会影响它的工作方式。放置的唯一区别在于它会在计算放置它的任何代码时执行。实际上,您应该将它们放在顶部,以便人们一眼就能看到文件的依赖项。这是它的传统位置。 关于ruby-Ruby'require'语句是在类定义内部还是外部?,我们在StackOverflow上找到一个类似的问题: h

ruby - require File.expand_path(..., __FILE__) 是最佳实践吗?

requireFile.expand_path(...,__FILE__)是要求项目中其他文件的最佳方式吗? 最佳答案 在Ruby1.9.2中+require_relative可能是更正确的方法。出于安全原因,require已更改为不包含您的'.'目录。添加了require_relative,以便为相对于您的调用脚本路径的模块提供本地文件解决方案。您可以searchhereonStackOverflow,特别是在“Whatisrequire_relativeinRuby?”中,以及互联网和查找使用技巧以及why-formessage

ruby - "require"默认查找的路径是什么?

在Ruby中,有人告诉我这样做require"some_file"Ruby会在某些地方寻找文件。我知道它会查找some_file.rb,但默认情况下它在哪里查找? 最佳答案 这取决于您的平台,以及Ruby的编译方式,因此没有“那个”答案。你可以通过运行找到:ruby-e'puts$:'不过,通常情况下,您拥有标准、站点和供应商Ruby库路径,包括每个路径下的架构、版本和通用目录。​​ 关于ruby-"require"默认查找的路径是什么?,我们在StackOverflow上找到一个类似的