草庐IT

Use_decl_annotations

全部标签

ruby-on-rails - rails/Prawn : how do I use rails helpers inside a Prawn class?

我正在尝试在prawn类中使用rails3.2助手,但rails抛出:undefinedmethod`number_with_precision'for#Prawn类classQuotePdfControllerdefshow@quote=current_user.company.quotes.where(:id=>params[:id]).firsthead:unauthorizedandreturnunless@quoterespond_with@quote,:layout=>!params[:_pjax]do|format|format.pdfdosend_dataQuotePd

ruby-on-rails - RubyOnRails : How do I use helper methods in Rails Console?

可能是我的设置有问题:irb(main):001:0>truncate("Onceuponatimeinaworldfarfaraway",:length=>17)NoMethodError:undefinedmethod`truncate'formain:Objectfrom(irb):1from/usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in`start'from/usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.8/lib/ra

ruby-on-rails - ruby /rails : Use `separator: ' -'` instead

正在为我的项目编写测试,并在运行rspec时注意到这个终端警告DEPRECATIONWARNING:Passingtheseparatorargumentasapositionalparameterisdeprecatedandwillsoonberemoved.Use`separator:'-'`instead.(calledfromadd_linkat/myapp/app/models/post.rb:37)我在保存记录之前有一个Action,看起来像self.link=theme+'-'+Time.now.to_formatted_s(:number)我试图找到一些关于这个的信息

ruby-on-rails - 测试速度 : ActiveRecord use_transactional_fixtures vs. DatabaseCleaner.strategy = :transaction

从来源(database_cleaner,active_record)来看,它们应该同样快。但是有人声称使用database_cleaner的事务策略会降低Controller和模型规范的速度(forexample)。我手头没有用于基准测试的大型测试套件。任何人有任何见解或比较两者? 最佳答案 我花了一点时间在广泛使用ActiveRecord固定装置的中型代码库上比较两者。当我将其切换为使用DatabaseCleaner而不是use_transactional_fixtures时,模型规范开始花费大约两倍的时间。在进行了与您相同的比

ruby-on-rails - ruby rails : Use slug instead of id on resource routes

因此,我正在寻找一种解决方案来帮助我使用Rails资源实现以下目标:/admin/articles/:slug/edit相对于/admin/articles/:id/edit我正在寻找Railsresourceroutes而不是其他类型的路线。只是想知道这是否可能。如果是这样,如何? 最佳答案 #config/routes.rbresources:articles,param::slug在终端中:$rakeroutes...articleGET/articles/:slug(.:format)articles#show...

ruby-on-rails - Need Advice : Is this a good use case for a 'NoSQL' Database? 如果有,是哪一个?

我最近一直在研究NoSql选项。我的场景如下:我们从位于世界各地偏远地区的定制硬件收集和存储数据。我们每15分钟记录一次来自每个站点的数据。我们最终希望每1分钟移动一次。每条记录有20到200个测量值。一旦设置好硬件,每次都会记录和报告相同的测量值。我们面临的最大问题是我们从每个项目中获得了一组不同的衡量标准。我们测量大约50-100种不同的测量类型,但是任何项目都可以有任意数量的每种测量类型。没有可以容纳数据的预设列集。因此,当我们在系统上设置和配置项目时,我们创建并构建了每个项目数据表,其中包含所需的确切列。我们提供工具来帮助分析数据。这通常包括更多的计算和数据聚合,其中一些我们也

ruby - 卡皮斯特拉诺 3 : use server custom variable in task

我有多阶段多服务器设置,在我的任务中我需要使用服务器名称例如在stagin.rb我有:set:stage,:staging#Defineserversserver'xxx.xx.xx.xxx',user:'deploy',roles:%w{app},name:'app1'server'xxx.xx.xx.yyy',user:'deploy',roles:%w{app},name:'app2'我想在我的任务中使用那个“名称”变量:task:configuredoonroles(:app),in::paralleldo#howdoIgetservernamehere?endend

ruby-on-rails - capybara 和 Rspec : correct way to use within() and have_selector() together?

我使用rspec2.6.0和Capybara1.1.1进行验收测试。具有如下View:Team3NametrueShowEditDeactivateTeam4NametrueShowEditDeactivate我想编写一个验收测试,声明:“团队3没有‘停用’链接。”我希望以下操作失败:within('tr',:text=>'Team3Name')do|ref|page.should_nothave_selector('a',:text=>'Deactivate')end但它过去了。为了进一步测试发生了什么,我写了荒谬的:lock=falsewithin('tr',:text=>'Tea

ruby - 在没有 rvm 或 rbenv 的情况下编译 Ruby 2.0 错误, `readline.c:1886:26: error: ' Function' undeclared (first use in this function)`

我想安装gitlab,不推荐使用任何ruby版本管理器。但是这是我的操作系统Linuxdqa-dev3.13.0-24-generic#46-UbuntuSMPThuApr1019:08:14UTC2014i686i686i686GNU/Linuxlinkingshared-objectpsych.soinstallingdefaultpsychlibrariesmake[2]:Leavingdirectory`/home/poc/ruby-2.0.0-p451/ext/psych'make[2]:Enteringdirectory`/home/poc/ruby-2.0.0-p451/

ruby-on-rails - rails : use jbuilder template in various controller methods

是否可以在另一个Controller方法中重用jbuilder-template?换句话说:如何明确地说Controller方法使用具体的jbuilder-template? 最佳答案 来自Railsguide.从另一个Controller渲染一个Action的模板。Whatifyouwanttorenderatemplatefromanentirelydifferentcontrollerfromtheonethatcontainstheactioncode?Youcanalsodothatwithrender,whichacce