问题标签 [ruby-on-rails-3]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
17 回答
546731 浏览

ruby-on-rails - 如何在 Ruby 中获取随机数

如何在0和之间生成随机数n

0 投票
6 回答
23984 浏览

ruby-on-rails - Rails:如何检查列是否有值?

我怎样才能做到这一点?

我想测试一下代理是否有一个单元格号码,如果有,显示条件里面的内容。我目前所拥有的似乎不起作用;它只显示“单元格:”。

想法?

0 投票
6 回答
23746 浏览

ruby-on-rails - 用于谷歌地图集成的 Ruby on rails gem

我想问一下哪个是将谷歌地图集成到 ruby​​ on rails 应用程序的最佳解决方案。一个特定的宝石值得还是我们应该为它写下自己的观点?

感谢您的任何意见。

0 投票
6 回答
10292 浏览

ruby-on-rails - 连接两个字段 activerecord

我已经习惯了 oracle 在那里你可以简单地

但是如果我使用 activerecord 来查找 field1 和 field2,并且我需要在两者之间留一个空格,我该如何完成呢?

为你的帮助干杯

0 投票
31 回答
562678 浏览

ruby-on-rails - 如何在 Ruby on Rails 迁移中重命名数据库列?

我错误地命名了一个列hased_password而不是hashed_password.

如何更新数据库架构,使用迁移重命名此列?

0 投票
2 回答
141 浏览

ruby-on-rails - What can I expect as the core stack for Rails 3.0 and what will I need to include now as a plugin

So Rails and Merb are sort of merging in Rails 3.0? Thats how its been described to me anyway. This means that a lot of what made Rails, Rails will now be moved to plug-ins so that it can be more lightweight. HOwever, what are those plug-ins going to be and as a new Rails developer, what are THE must have - and also more mature - plug-ins that a Rails developer should install? Some good examples I can think of might be will_paginate, ruby_prof or sqlite3-ruby.

0 投票
3 回答
1846 浏览

ruby-on-rails - 绕过 attr_accessible/protected in rails

我有一个模型,当它实例化一个对象时,它还会创建另一个具有相同用户 ID 的对象。

在 Bar.rb 中,我有 attr_protected 以保护它免受黑客攻击。

就目前而言,如果不禁用 attr_protected 或让 Bar 对象的 user_id 变为空白,我似乎无法创建新的 Bar 对象......

如何让 bar 对象接受来自 foo 的 :user_id 属性而不失去来自 attr_protected 的保护?

0 投票
4 回答
9780 浏览

ruby-on-rails - rspec 如何与 Rails 3 一起进行集成测试?

我想要实现的是在rails3 中使用 webrat 进行集成测试,就像 Yehuda 在http://pivotallabs.com/talks/76-extending-rails-3第 34 分钟中使用 test-unit 所做的那样。

一个例子:

有人知道一种方法吗?

0 投票
1 回答
4588 浏览

ruby-on-rails - Bundler isn't loading gems

I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I defined my Gemfile like so:

#xA;

Then I run gem bundle, it bundles it all up like expected. Inside the environment.rb file that is included within boot.rb it looks like this:

#xA;

But when I try to access any of my gems, e.g. MongoMapper, Paperclip, Haml, etc. I get:

#xA;

The same goes for any other gem. Does Bundler not include gems like the old Rails 2.0 did? Or is something messed up with my system?

Any help would be appreciated, thank you!

0 投票
2 回答
5168 浏览

ruby-on-rails - Rails 3 / Bundler gem:'Bundler:Module(NoMethodError)的未定义方法'setup''

可以追溯到 config/boot.rb 第 7 行:

这是据称安装的 Bundler 0.8.1:

我所做的一切都遵循本指南。任何人都知道有什么问题吗?

谢谢 :)