草庐IT

java在运行时动态增加xmx

全部标签

ruby-on-rails - Rails 3 动态添加虚拟属性

我的设置:Rails3.0.9、Ruby1.9.2我这样做有我的理由,但我需要的是一种将虚拟属性动态添加到activerecord结果集的方法。这意味着我没有在模型中使用attr_accessor,而是希望将虚拟属性动态添加到结果集中。例如,users=User.all#auserhasfollowingattributes:name,email,password我喜欢做的是说添加(不使用attr_accessor)虚拟属性status到users,这可能吗? 最佳答案 你应该这样做:users.eachdo|user|user.i

ruby-on-rails - 如何运行 "rails s"

我在Ubuntu中运行railss时遇到问题。当我键入railss时,它不会启动服务器,而是输出:kyala@ubuntu:~/depot$railssUsage:railsnewAPP_PATH[options]Options:-r,[--ruby=PATH]#PathtotheRubybinaryofyourchoice#Default:/home/kyala/.rvm/rubies/ruby-1.9.2-p290/bin/ruby-d,[--database=DATABASE]#Preconfigureforselecteddatabase(options:mysql/oracl

ruby - 运行错误 '__rvm_make install'

我是编程新手,尝试使用RVM添加Ruby2.2并收到以下错误。我已经运行rvmgetstable并尝试重新安装,但出现了同样的错误。$rvmreinstallruby-2.2.0Searchingforbinaryrubies,thismighttakesometime.Nobinaryrubiesavailablefor:osx/10.10/x86_64/ruby-2.2.0.Continuingwithcompilation.Pleaseread'rvmhelpmount'togetmoreinformationonbinaryrubies.Checkingrequirements

ruby-on-rails - 在 Rails 中是否可以动态加载类布局?

我需要消息在项目中有不同的布局,是否可以在Rails中做这样的事情?ClassMessages::New谢谢 最佳答案 这对你有帮助classMessagesController 关于ruby-on-rails-在Rails中是否可以动态加载类布局?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/1274999/

ruby-on-rails - Controller : Circular dependency detected while autoloading constant 中的 Rails 4 运行时错误

如果我遗漏了什么,请告诉我。我不明白为什么无法访问我的views/references/文件夹。new.html.erb和index.html.erb都不可用。当我转到localhost:3000/references时,我的错误是:RuntimeErrorinReferencesController#indexCirculardependencydetectedwhileautoloadingconstantReferencesController我相信这是设置,它不应该是Rails问题,因为我的其他Controller工作正常。我的路线文件中有resources:reference

ruby - 更新到 cocoapods 0.32.1 后无法运行 sudo pod install,错误为 "You cannot run CocoaPods as root. (CLAide::Help)"

我在更新到最新版本0.32.1后运行sudopodinstall命令时发现了一个问题。早些时候它工作得很好。当我尝试使用旧的cocoapods安装pod时,它要求我更新到最新的cocoapods版本,即0.32.1。在我通过cocoapodsgem更新后,我无法在我的Xcode项目中执行sudopodinstall。它给了我以下错误。±sudopodinstallruby-1.9.3-p0Password:/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/gems/1.9.1/gems/claide-0.5.0/lib/claide/

ruby-on-rails - 无法运行 `bundle install`

所以前几天我遇到了严重的硬盘问题,不得不手动删除我的.gem文件夹。我试图通过进入我的项目文件夹运行bundleinstall来为我的应用程序重建gem...不幸的是我遇到了这个错误:/home/xxx/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in`require':cannotloadsuchfile--bundler(LoadError)from/home/xxx/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2

ruby-on-rails - 使用 get 和 delete 运行 Rspec 测试时获取错误数量的参数(2 个为 0)

这应该是一个简单的问题,就是找不到导致测试失败的原因。运行rspec时,我不断收到以下错误。但是在评论“发送”方法之后,一切正常。1)MessagesGET/messagesworks!(nowwritesomerealspecs)Failure/Error:gettarget_app_messages_path(@message.target_app.id)ArgumentError:wrongnumberofarguments(2for0)#./app/controllers/messages_controller.rb:37:in`send'路线.rbresources:targ

ruby - 使用 attr_accessor 动态创建类属性

在Ruby中,有没有办法动态地向类中添加实例变量?例如:classMyClassdefinitializecreate_attribute("name")enddefcreate_attribute(name)attr_accessorname.to_symendendo=MyClass.newo.name="Bob"o.name 最佳答案 一种方法(还有其他方法)是这样使用instance_variable_set和instance_variable_get:classTestdefcreate_method(name,&bloc

ruby-on-rails - 在 RSpec 2 中动态生成共享示例?

我试图通过创建一个共享示例组来保持我的规范干燥,该示例组对所有管理Controller(我项目的Admin命名空间下的所有Controller)执行样板检查。我正在努力弄清楚如何去做,因为共享示例需要提供有关要使用的操作和参数的信息。如果测试失败,理想情况下它应该显示有意义的错误(即包括它正在测试的操作的详细信息)。require'spec_helper'shared_examples"anadmincontroller"dobefore(:each)do@non_admin=User.make@admin=User.make(:admin)endcontext"asanadminus