Tag: ruby 1.9

我应该在我的新网络应用程序中使用Ruby 1.9.2吗?

使用Rails 3开始一个新的Web应用程序。我仍然是Web开发的新手,并且非常喜欢在使用Ruby 1.8.7和Rails 2.3.5时可用的所有Internet资源。 有关在我的新项目中使用Ruby 1.9.2的任何建议吗?

正则表达式“\ w”不处理Ruby 1.9.2中的utf-8字符

Regex \w与Ruby 1.9.2中的utf-8字符不匹配。 有人遇到同样的问题吗? 例: /[\w\s]+/u 在我的rails application.rb中我添加了config.encoding = “utf-8”

为什么我的rake调用导致’未定义的方法`source_index`’错误?

我试图运行bundle exec rake db:migrate然后遇到以下错误。 bundle exec rake db:migrate –trace ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method `source_index’ for Gem:Module C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/initializer.rb:298:in `add_gem_load_paths’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/initializer.rb:132:in `process’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/initializer.rb:113:in `run’ C:/Program Files/chiliproject-3.7.0/config/environment.rb:42:in `’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `block in require’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:547:in `new_constants_in’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/tasks/misc.rake:4:in `block in ‘ C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call’ C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in […]

不支持从define_method()定义的方法传递super的隐式参数

在“ 使用Rails的敏捷Web开发 ”(第三版)第537-541页中,它具有“自定义表单构建器”代码,如下所示: class TaggedBuilder < ActionView::Helpers::FormBuilder # # Description # # def self.create_tagged_field(method_name) define_method(method_name) do |label, *args| @template.content_tag(“p” , @template.content_tag(“label” , label.to_s.humanize, :for => “#{@object_name}_#{label}”) + “” + super) end end field_helpers.each do |name| create_tagged_field(name) end end 此代码不适用于Ruby 1.9.1。 它返回错误如下: implicit argument passing of super from method defined by define_method() is not supported. Specify […]

纸夹无法保存附件

我正在使用带有Paperclip gem的Ruby 1.9和Rails 2.3.4来保存附件。 我通过添加适当的迁移,向模型添加(has_attached_file:video),制作表单(multipart)并向其添加来跟踪教程… 当我尝试上传文件时,我会查看日志,然后看到: [paperclip] Saving attachments. 但是文件并没有真正上传,而且回形针添加的额外字段都是NULL! 事实上,它没有抛出任何错误让我困惑在哪里开始寻找可能的问题。 我正在使用MAC OSX Leopard,它是否可能是权限的东西? 如果是这样,我怎么能给我的应用程序“sudo”权限? 任何想法是什么问题或如何显示更好的日志记录,以了解在哪里寻找问题。 谢谢, 谭 日志: SQL (0.2ms) SET NAMES ‘utf8’ SQL (0.2ms) SET SQL_AUTO_IS_NULL=0 Processing PostsController#create (for 127.0.0.1 at 2009-09-26 17:08:26) [POST] Parameters: {“authenticity_token”=>”ZhEzTVQScgZxV9KY0Eo+sG5sHwn1kHgykvy11ovvfSU=”, “post”=>{“title”=>”asd fasdf “, “description”=>”asdf as fasd f”, “video”=>#, “video_link”=>””, “is_notify_when_comment”=>”0”}} I’m in load_user User Columns (3.7ms) SHOW […]

如何在Heroku上选择Ruby版本?

我在我的Rails 3应用程序中使用了Ruby 1.9.x语法,但在将其推送到Heroku之后,由于旧的Ruby版本(1.8)而崩溃。 我该如何控制它?

升级到Rails 3后,为什么所有字符串都是ASCII-8BIT?

我升级到RoR 3.0.1和Ruby升级到1.9.2。 现在我视图中的所有字符串都是ASCII-8BIT? 我相信我的应用程序设置为使用UTF 8 application.rb中 config.encoding = “utf-8” database.yml的 development: adapter: mysql encoding: utf8 我在跑 OS X RVM rvm 1.0.16 Ruby ruby-1.9.2-p0 Rails 3.0.1 我希望编码是UTF 8而不是ASCII business.desc.encoding # ASCII-8BIT 由于1.9.x可以连接不同编码的字符串,我们会看到很多这样的错误。 17) %> 错误 incompatible character encodings: ASCII-8BIT and UTF-8 activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat’ activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat’ actionpack (3.0.1) lib/action_view/template/handlers/erb.rb:14:in `<<' app/views/browse/businesses.html.erb:15:in `block in […]

为什么Ruby 1.9.2会破坏JSON gem依赖?

我遇到了JSON gem和Ruby 1.9.2的问题。 我正在升级到Rails 3.0.3,每当我尝试启动环境时它都会爆炸。 这是一个空的测试项目,只有JSON gem 1.4.6作为依赖项。 /Users/lee/.rvm/gems/ruby-1.9.2-p0/gems/json-1.4.6/lib/json/common.rb:66: [BUG] unknown type 0x22 (0xc given) ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0] — control frame ———- c:0032 p:—- s:0096 b:0096 l:000095 d:000095 CFUNC :initialize c:0031 p:—- s:0094 b:0094 l:000093 d:000093 CFUNC :new c:0030 p:0085 s:0091 b:0089 l:000088 d:000088 METHOD /Users/lee/.rvm/gems/ruby-1.9.2-p0/gems/json-1.4.6/lib/json/common.rb:66 c:0029 p:0090 s:0081 b:0080 l:000079 d:000079 […]

聋人奶奶的错误 – 松 – 没法

正在为Def奶奶完成松树运动,并且思考会尝试进一步采取并抽象它以尽可能多地删除重复。 希望我对此的逻辑并不是太过分,只是试图将事物分离成函数。 但现在如果我输入 Bye 程序立即退出而不进入exitPlan函数。 欢迎任何建议。 puts ‘Say something nice to Grandma.’ puts ‘You may need to shout > ‘ speak = gets.strip counter = 0 speaks(speak) def speaks(speak) if speak != ‘Bye’ talk() else exitPlan() end end def talk() if speak == speak.downcase puts ‘Huh Speak up Sonny’ counter -= 1 else year = […]

ruby不需要工作

我是ruby的新手,但我正在研究我的第一个ruby计划。 它目前有两个文件,一个是函数库(存储在lib xgync.rb ),另一个是存储在’bin’中的可执行文件xgync 。 (项目在这里可见https://bitbucket.org/jeffreycwitt/xgync/src )我还为我的/usr/local/bin/xgync创建了一个符号链接,以便我可以从任何地方编写命令xgync {arguments}终奌站。 问题似乎是bin/xgync依赖于库lib/xgync.rb 。 我在bin/xgync编写了这个依赖bin/xgync ,如下所示: $:.unshift(File.dirname(__FILE__) + ‘/../lib’) require “xgync” 但是,我不断收到以下错误: /Users/JCWitt/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: cannot load such file — xgync (LoadError) from /Users/JCWitt/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’ from /usr/local/bin/xgync:4:in `’ 你能看到我写的东西有什么问题吗? 符号链接可能会以某种方式弄乱事物吗? 谢谢你的帮助 :)