jjzjj

beta-reports-active

全部标签

ruby - 时间 :Class after requiring active_support/time_with_zone 的未定义方法 `zone`

我在使用Ruby2.2.1并安装了active_support4.2,所以我想使用Time.zone.parse('2007-02-1015:30:45')如此处所述:http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html但即使在需要active_support和active_support/time_with_zone之后,我觉得Time.zone仍然不起作用。观察:2.2.1:002>require"active_support"=>true2.2.1:003>Time.zoneNoMethodError

ruby-on-rails - Ruby 2.0/Rails 4.0.0beta 升级在推送到 heroku 时失败

脑子转储,因为我的脑袋被谷歌搜索和猛撞电脑弄得焦头烂额。任何帮助或线索将不胜感激!我通过rvm管理我的gem。$ruby-vruby2.0.0p0(2013-02-24revision39474)[x86_64-darwin12.2.0]$rails-vRails4.0.0.beta1然后当我想从头开始创建一个全新的应用程序$railsnewbrand_new_appcreatecreateREADME.rdoc...Yourbundleiscomplete!Use`bundleshow[gemname]`toseewhereabundledgemisinstalled.$cdbran

ruby-on-rails - 为什么都是autoload,load_all!并要求全部用于 active_support.rb?

我正在查看active_support.rb以尝试了解它使用的加载过程。它使用三种加载方法:load_all!、autoload和require。为什么在同一个文件中使用三种不同的加载方式?moduleActiveSupportdefself.load_all![Dependencies,Deprecation,Gzip,MessageVerifier,Multibyte,SecureRandom,TimeWithZone]endautoload:BacktraceCleaner,'active_support/backtrace_cleaner'autoload:Base64,'ac

ruby - 使用 RVM 使用 sinatra 应用程序加载 Active Record gem 时出错

我为我正在启动的sinatra应用程序设置了一个项目级RVMgemset,它将使用ActiveRecord连接到本地数据库。为了测试它,我尝试运行以下测试应用程序:测试.rbrequire'rubygems'#maynotbeneeded,dependingonplatformrequire'sinatra'require'activerecord'classArticle"sqlite3",:database=>"hw.db")Test.first.contentend(摘自这个问题的答案:What'sthebestwaytotalktoadatabasewhileusingSina

ruby-on-rails - 如何获取 Active Storage 图像的 url

我想通过api获取带有附加图像的记录列表作为链接或文件。我有一个简单的模型:classCategory下一步行动:defindex@categories=Category.all.with_attached_imagerenderjson:@categories.to_json(include:{image_attachment:{include::blob}})end这是我获得图像对象的唯一方法。我看到下一个结果:{"id":4,"name":"Cat1","description":""},{"id":1,"name":"Cat2","description":"","image_

ruby - 您如何处理 Active Admin 资源中的序列化编辑字段?

我有一个模型,Domain,它有一个文本字段,names。>railsgmodelDomainnames:textinvokeactive_recordcreatedb/migrate/20111117233221_create_domains.rbcreateapp/models/domain.rb>rakedb:migrate==CreateDomains:migrating==================================================--create_table(:domains)->0.0015s==CreateDomains:migrat

ruby - 配置Active Admin的标签has_many

好吧,我有两个与一对多关联相关的模型。#models/outline.rbclassOutlinetruef.input:pages,:required=>true...f.buttonsendf.inputs"DocumentVersions"dof.has_many:documents,:name=>"DocumentVersions"do|d|d.input:file,:as=>:filed.buttonsdod.commit_button:title=>"AddnewDocumentVersion"endendendendend正如您在admin/outlines.rb中看到的

ruby-on-rails - attr_accessible 在 rails Active Record 中

当我使用attr_accessible指定我将公开模型中的哪些字段时,脚本/控制台也是如此吗?我的意思是我没有指定为attr_accessible的东西也不能通过控制台访问? 最佳答案 这仅适用于批量分配。例如,如果您要在模型中设置attr_protected:protected:>>Person.new(:protected=>"test")=>#相反,您可以使用attr_accessible将您想要的所有属性设置为可访问。但是,以下内容仍然有效:>>person=Person.new=>#>>person.protected="

ruby-on-rails - 将 PG::Result 转换为 Active Record 模型

pg-ruby允许您一次性向数据库发送多个查询,这有助于最大限度地减少访问数据库的次数:results=[]conn.send_query('QUERY1;QUERY2;QUERY3')conn.blockwhileresult=conn.get_resultresults假设对于任何result我已经知道ActiveRecord模型,将结果转换为模型的合适方法是什么?现在我正在做以下事情:fields=result.fieldsmodels=result.values.map{|value_set|Model.new(Hash[fields.zip(value_set)])}该方法的

ruby-on-rails - 停用 Gem - "you have already activated rake 0.9.3.beta.1, but my Gemfile requires rake 0.9.2"

我正在尝试运行迁移,但我不断收到错误消息:rakeaborted!Undefinedmethodprerequisitefornil:NilClass.似乎我以某种方式激活了一个名为rake0.9.3.beta.1的gem-但是我已经更改了gembundleinstall并运行bundleshowrake并且它显示安装了rake0.9.2。我是第一次使用Git,所以我认为这可能与仍在使用测试版rake的应用程序有关-但我已经完成了推送,它显示gemfile已更新。当我向下查看gem库时,我只能看到rake0.9.2版本。我应该看哪里?我还有一条Rails:Railtie弃用警告-但我认