jjzjj

file_time_type

全部标签

ruby-on-rails - time_ago_in_words 和本地化

是否可以将time_ago_in_words与i18n.locale一起使用?如何?谢谢 最佳答案 如果您使用的是Rails>2.2,则该帮助器已经可以识别区域设置。只需从localerepository下载正确的本地化文件即可并将其存储到您的/config/locales路径中。然后设置您的语言环境首选项。 关于ruby-on-rails-time_ago_in_words和本地化,我们在StackOverflow上找到一个类似的问题: https://st

ruby-on-rails - TimeWithZone & Time.zone.now 集成测试失败

在Controller方法中,当向用户发送激活电子邮件时,我将用户变量activation_sent_at设置为等于Time.zone.now。在开发服务器上,这似乎可行(尽管我的应用程序中的时间表达式比我计算机的本地时间晚2小时)。我想包括一个集成测试,测试activation_sent_at是否确实设置正确。所以我包括了这一行:assert_equal@user.activation_sent_at,Time.zone.now但是,这会产生错误:NovisibledifferenceintheActiveSupport::TimeWithZone#inspectoutput.You

ruby-on-rails - 在 RSpec 中使用 Ruby 1.9.2 需要 lib 带来 "no such file to load"

我正在尝试将我的一个Rails项目升级到Ruby1.9.2。一切进展顺利,但一个RSpec测试失败了。在这个测试中,我需要一个Rubylib:#filespec/models/my_lib_spec.rbrequire'spec_helper'require'lib/services/my_lib'describe"MyLib"doit"shoulddosomething"do...库看起来像这样:#filelib/services/my_lib.rbclassMyLibdefself.do_something...在Ruby1.8.7(REE)中测试运行良好:$ruby-vruby1

ruby-on-rails - Heroku 应用程序崩溃 H10 - bash : bin/rails: No such file or directory

这个问题在这里已经有了答案:"bin/rails:Nosuchfileordirectory"w/Ruby2&Rails4onHeroku(8个答案)关闭8年前。我的部署有问题。我的测试环境在本地运行良好,没有错误。当我推送到Heroku时,我得到了这个:2013-07-17T15:54:04.619297+00:00app[web.1]:bash:bin/rails:Nosuchfileordirectory2013-07-17T15:54:07.240398+00:00heroku[web.1]:Processexitedwithstatus1272013-07-17T15:54:

ruby - jruby -S bundle install jruby : No such file or directory -- bundle (LoadError)

我有我的ruby​​onrails应用程序,我已经在我的WindowsXP中安装了jruby-1.7.4。当我尝试运行jruby-Sbundleinstall时,它给我一个错误jruby:Nosuchfileordirectory--bundle(LoadError)我真的很纠结这个错误..请帮助.. 最佳答案 Bundler可能没有安装。您可以检查jruby-Sgemlist的输出来验证,然后安装它:jruby-Sgeminstallbundler一般来说,LoadError意味着您缺少gem依赖项。

ruby-on-rails - 回形针错误 : model missing required attr_accessor for 'avatar_file_name'

然后我想使用Paperclip为每个列表拍摄照片。我向listshow.html.erb、listing.rb模型、listings_controller.rb和_form.html.erb部分添加了适当的代码。当我尝试为list上传图片时出现此错误:Paperclip::ErrorinListingsController#updateListingmodelmissingrequiredattr_accessorfor'avatar_file_name'listings_controller的第44行:defupdaterespond_todo|format|if@listing.u

ruby-on-rails - ruby 包安装需要 : no such files to load error

我在通过git克隆的应用程序的bundleinstall安装gems时遇到了麻烦。这是bundleinstall的输出:bundleinstall/usr/lib/ruby/vendor_ruby/bundler/rubygems_ext.rb:8:in`require':nosuchfiletoload--rubygems(LoadError)from/usr/lib/ruby/vendor_ruby/bundler/rubygems_ext.rb:8from/usr/lib/ruby/vendor_ruby/bundler.rb:11:in`require'from/usr/lib

ruby - 导轨 : how to get a file extension/postfix based on the mime type

我的问题是,RubyonRails是否具有类似于以下的功能:file_content_type=MIME::Types.type_for(file).first.content_type这将返回特定mime类型的文件扩展名或后缀?所以如果我传入'image/jpeg'函数将返回'jpg'寻找一种比编写完成相同工作的case语句更简洁的编码方式。 最佳答案 Rack::Mime具有这种能力(Rack是Rails的依赖):require'rack/mime'Rack::Mime::MIME_TYPES.invert['image/jpe

ruby-on-rails - 计算两个 Time 对象之间的时间差

假设我从我的用户模型中创建了两个时间对象:created=u.created_atupdated=u.updated_at如何计算两个时间对象之间的小时差?hours=created-updated我想将它包装在一个方法中并扩展Time类。我很难相信我需要扩展它,但我似乎无法找到一种本地方法来处理使用不同时间单位计算耗时。 最佳答案 这应该有效:hours=((created-updated)/1.hour).round相关问题:RailsTimedifferenceinhours 关于

ruby - 加载错误 : cannot load such file -- rspec/core/rake_task

当我rake的时候,我得到了这个错误。AllenLins-MacBook-Pro:geoblacklightallenlin$rake-tResolvingdependencies...Youmust`geminstallbundler`and`bundleinstall`torunraketasksrakeaborted!LoadError:cannotloadsuchfile--rspec/core/rake_task/Users/allenlin/Documents/USpatial/geoblacklight/Rakefile:12:in`require'/Users/alle