在rails >4.0.0生成器使用before_action而不是before_filter创建CRUD操作。它似乎做着同样的事情。这两者有什么区别呢?

用户上传次数过多。我想在上传表中添加一个引用用户的列。迁移应该是什么样的?

这是我有的。我不确定我是否应该使用(1):user_id,:int或(2):user,:引用。我甚至不确定(2)是否有效。我只是想按"铁轨"的方式来。

class AddUserToUploads < ActiveRecord::Migration
  def change
    add_column :uploads, :user_id, :integer
  end
end

除了Rails 3之外的相关问题。Rails 3迁移:添加参考列?

我刚刚更新到rails 4.0.2,我得到了这个警告:

(弃用)I18n。enfort_available_locales将来将默认为true。如果你真的想跳过locale验证,你可以设置I18n。enfort_available_locales = false以避免此消息。

设置为false是否存在安全问题?

update_attributes是否有不保存记录的替代方法?

所以我可以这样做:

@car = Car.new(:make => 'GMC')
#other processing
@car.update_attributes(:model => 'Sierra', :year => "2012", :looks => "Super Sexy, wanna make love to it")
#other processing
@car.save

顺便说一下,我知道我可以@车。model = 'Sierra',但我想在一行中更新它们。

I ran into an issue in my Rails 4 app while trying to organize JS files "the rails way". They were previously scattered across different views. I organized them into separate files and compile them with the assets pipeline. However, I just learned that jQuery's "ready" event doesn't fire on subsequent clicks when turbo-linking is turned on. The first time you load a page it works. But when you click a link, anything inside the ready( function($) { won't get executed (because the page doesn't actually load again). Good explanation: here.

所以我的问题是:什么是确保jQuery事件在涡轮链接打开时正常工作的正确方法?您是否将脚本包装在特定于rails的侦听器中?或者也许rails有某种魔力,使它变得不必要?文档对这应该如何工作有点模糊,特别是关于通过manifest(s)加载多个文件,如application.js。

在哪里可以找到Ruby on Rails 4中使用的数据类型列表? 如

文本 字符串 整数 浮动 日期

我一直在学习新的东西,我想有一个清单,我可以很容易地参考。

缺省的Rails 4项目生成器现在在控制器和模型下创建目录“关注点”。我找到了一些关于如何使用路由关注点的解释,但没有关于控制器或模型的解释。

我很确定这与当前社区中的“DCI趋势”有关,我想尝试一下。

问题是,我应该如何使用这个功能,为了使它工作,如何定义命名/类层次结构是否有一个约定?如何在模型或控制器中包含关注点?