jjzjj

Getting-started-with-red

全部标签

ruby-on-rails - 是否有类似 'with_indifferent_access' 的数组可用于包含?

我尝试在我的应用中只使用:symbols作为关键词。我尝试在:symbol=>logic或string=>UI/languagespecific之间做出严格的决定但我也得到了每个JSON的一些“值”(即选项等),因为JSON中没有:symbols,所以我调用的所有哈希都具有“with_indifferent_access”属性。但是:数组是否有相同的东西?像那样a=['std','elliptic',:cubic].with_indifferent_accessa.include?:std=>true?编辑:将rails添加到标签 最佳答案

ruby-on-rails - rails 5 : Autoloading with custom folders not working

我有这门课:#app/events/new_request.rbclassEvents::NewRequestend然后我将该文件夹添加到自动加载:#config/application.rbconfig.autoload_paths+=%W(events/)当运行railsc时:>Events::NewRequestNameError:uninitializedconstantEvents问题是,如果我在定义类时不使用命名空间“Events”,它会成功自动加载类。 最佳答案 moduleSandboxclassApplicatio

ruby-on-rails - rails 2.3.8, ruby 1.8.6 : Getting a visual call tree/graph of what methods call what?

我有一个中等复杂度的Rails应用程序。主Controller(执行应用程序所要做的事情的Controller)只有一个操作方法。(它不是标准的RESTful应用程序;它充当中介,并且对其调用方式有外部限制。)但是,它确实有很多方法和一些过滤器,以及一个不断增长的测试套件。随着时间的推移,结构发生了很大变化,我不再相信为之前编写的测试设置的某些Mocha期望仍然合适。有多个人在开发该应用程序,因此我正在构建一本用于编写功能测试的指南。“当你想在有/没有[那些]副作用的情况下进行测试时,使用[这些]期望和断言”等等。调用树/图在编写此类文档时非常有用。除了过滤器之外,这些甚至可以静态地从

ruby-on-rails - Rails 4 Has_many :through join association with select

我正在尝试将Rails3.0应用程序升级到Rails4.0。我注意到的行为之一是模型之间的关系停止工作。假设我们有以下模型:classStudent:teacher_students,:select=>'teacher_students.met_with_parent,teachers.*'#TheRails4syntaxhas_many:teachers,->{select('teacher_students.met_with_parent,teachers.*')},:through=>:teacher_studentsendclassTeacher:teacher_student

ruby-on-rails - ActionController::UnknownFormat 当我使用 respond_to + respond_with (Rails 4)

我无法理解发生了什么,当我请求索引操作时,我收到了ActionController::UnknownFormat,甚至在views/products文件夹中存在一个index.js文件。任何人都可以帮我弄清楚我错过了什么?我正在使用Rails4和Ruby2.0.0-p247。classProductsController 最佳答案 您应该在请愿书上指定格式,即:获取:show,:user_id=>user_id,:format=>:json 关于ruby-on-rails-ActionC

ruby-on-rails - Rails with angular 与 Rails pure(查看性能)

我尝试在Internet上搜索有关使用angularJS进入RubyonRails项目与RubyonRailspure的View性能的信息。我的问题是因为2个月前我开始使用纯AngularJS,现在我需要将AngularJS集成到一个新项目中,但需要展示使用带有RubyonRails的AngularJS呈现View的性能如何,并消除对RubyonRails的负担.例如:带Rails的Angular:使用RubyonRails获取数据(从数据库或GET请求),将信息发送到file.js.erb并使用AngularJS操作数据并显示带有解析数据的View。纯粹的Rails:(自然流程)使用

ruby-on-rails - 我可以在 :all with capybara? 之前使用吗

我有一个这样的描述block:describe"Documents"dosubject{page}let(:course){FactoryGirl.create(:course)}describe"new"dobeforedovisitnew_course_document_path(course)fill_in"Name",with:"TestDocument"attach_file"Originaldocument","#{Rails.root}/spec/fixtures/03_GUI_concurrency.pdf"endit{shouldhave_selector('titl

ruby - 为什么在:save callback hook not getting called from FactoryGirl. create()之前?

这个简单的示例使用DataMapper的before:save回调(又名Hook)来增加callback_count。callback_count初始化为0,回调应该设置为1。当通过以下方式创建TestObject时调用此回调:TestObject.create()但是当FactoryGirl通过以下方式创建时会跳过回调:FactoryGirl.create(:test_object)知道为什么吗?[注意:我正在运行ruby​​1.9.3,factory_girl4.2.0,data_mapper1.2.0]详细信息如下...DataMapper模型#file:models/test_

ruby-on-rails - Jobs with Resque gives "Don' t know how to build task 'jobs:work' "on Heroku

我遵循了https://devcenter.heroku.com/articles/queuing-ruby-resque上的教程在Rails应用程序中排队和运行后台作业。在对作业进行排队后,它似乎没有运行任何作业,因为在控制台中我可以看到作业尚未处理>Resque.info=>{:pending=>1,:processed=>0,:queues=>1,:workers=>0,:working=>0,:failed=>0,:servers=>["redis://dory.redistogo.com:9826/0"],:environment=>"production"}如果我尝试(本地

ruby-debug19 : Can't get working with Ruby 1. 9.1p376

我正在尝试将ruby​​-debug19与Ruby1.9.1p376一起使用,但出现以下错误:test.rb:2:in`require':nosuchfiletoload--ruby-debug19(LoadError)fromtest.rb:2:in`'这是测试.rb:require'rubygems'require'ruby-debug19'这是“gemlist”的输出:***LOCALGEMS***ruby-debug19(0.11.6)(etc.)因此运行“rubytest.rb”会产生上述错误。我做错了吗?我认为这是运行ruby​​-debug19的正确方法(通过包含gem并