arel

arel

文章 0 浏览 3

Rails控制器接收所有参数,但无法正确创建数据库记录

我要开门见山了,根据我的日志文件,当我提交表单创建新记录时,所有参数都发送正确,但是创建记录时有些属性设置失败在数据库中。以下是相关日志条目…

相对绾红妆 2024-11-09 05:47:36 3 0

如何对 AREL 中的分组列求和

在 Rails 3/AREL Model.group(:label).sum(:value) SELECT sum(value), label from model_table group by label 中我会尝试找到 AREL 的做法 SELECT s…

寻梦旅人 2024-11-06 19:48:13 3 0

查询 ARel 中的关系

我正在做这样的事情: @invoices = Invoice.order(:due_date) @invoices = @invoices.where(:invoiced => true) 现在,我想按相关模型的 id 过滤发票…

笑着哭最痛 2024-11-03 14:02:35 4 0

有没有办法使用 AREL 进行自定义关联?

model Post # ActiveRecord associations have tons of options that let # you do just about anything like: has_many :comments has_many :spam_co…

星光不落少年眉 2024-11-03 10:34:18 5 0

Rails 3 查询:如何获取浏览次数最多的产品/文章/其他内容?

我一直想知道如何查询并获取不适合模型的结果。与使用 LINQ 并投影到匿名对象中的完成方式类似。 这是一个简单的模式: # Product.rb class Product <…

时常饿 2024-11-03 05:38:26 5 0

我如何将其转换为 MetaWhere 或 Arel?

考虑一个城市模型具有: def self.search(field, search) if search where("#{field} LIKE ?", "%#{search}%") else scoped end end 在知道该字段是字…

摘星┃星的人 2024-11-02 16:41:09 5 0

在哪里可以找到好的 AREL 文档?

Closed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not …

并安 2024-11-01 09:47:22 5 0

Rails/Arel:选择所有记录作为 ActiveRecord::Relation

在 Rails 中使用 Arel - 我正在寻找一种创建 ActiveRecord::Relation 的方法,该方法可以有效地生成 SELECT * FROM table,我仍然可以进一步操作它。 …

说不完的你爱 2024-10-31 08:19:53 7 0

Rails 3 ActiveRecord查询:查找该用户已订购的该产品的数量

我有一个 belongs_to :user 的 order 模型、一个 product 模型、一个连接模型 order_product class OrderProduct < ActiveRecord::Base belongs_to :o…

半枫 2024-10-28 08:19:02 5 0

如何使用 should_receive 规范 ActiveRecord::Base.find(something).method ?

假设我们有以下代码: class Post < ActiveRecord::Base def self.fix_published_times where(:published => true, :published_at => nil).limit(5).e…

浅唱々樱花落 2024-10-25 12:45:08 4 0

如何订购 Rails 3 中包含的元素

我有一个模型关系,其中 today 有许多 tasks 我正在尝试检索用户的 today 对象,包括 tasks code> 并将它们全部渲染为 Json。所有这一切都进展顺利,…

享受孤独 2024-10-22 18:56:56 7 0

想要查找 Rails 中没有关联记录的记录

考虑一个简单的关联... class Person has_many :friends end class Friend belongs_to :person end 让所有在 ARel 和/或 meta_where 中没有朋友的人最…

森林迷了鹿 2024-10-22 07:47:04 6 0

User.where(:id => [1,2]).where(:id => 2).arel.to_sql 意外结果

在 Rails 控制台中,运行以下命令会产生意外结果: User.where(:id => [1,2]).where(:id => 2).arel.to_sql => "SELECT `users`.* FROM `users` WHERE…

为你拒绝所有暧昧 2024-10-22 07:03:06 10 0

有没有办法反转 ActiveRecord::Relation 查询?

假设我们有以下内容: irb> Post.where(:hidden => true).to_sql => "SELECT `posts`.* FROM `posts` WHERE posts.hidden = 1" 我们能否以某种方式从…

み青杉依旧 2024-10-22 01:30:17 3 0

Rails 3、RSpec 2.5:在命名范围中使用 should_receive 或 Stub_chain

我使用 Rails 3.0.4 和 RSpec 2.5。在我的控制器中,我大量使用命名范围,例如, @collection = GuestbookEntry.nonreplies.bydate.inclusive.paginat…

丿*梦醉红颜 2024-10-21 00:19:02 5 0
更多

推荐作者

胡图图

文章 0 评论 0

zt006

文章 0 评论 0

z祗昰~

文章 0 评论 0

冰葑

文章 0 评论 0

野の

文章 0 评论 0

天空

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文