【发布时间】:2009-11-04 16:53:52
【问题描述】:
我有一个运动队数据库,我在表格/排名中显示。相关代码涉及到两个模型,Tableposition 和 Draw,它们以 has_one 关系关联。以下静态命名范围声明完美运行:
class Tableposition < ActiveRecord::Base
belongs_to :draw
named_scope :grouptable, :include => :draw, :conditions => ['draws.group = ?', "B"]
end
但是,当我尝试使其动态化时:
class Tableposition < ActiveRecord::Base
belongs_to :draw
named_scope :grouptable, :include => :draw,
lambda { |group| { :conditions => ['draws.group = ?', group] } }
end
我收到以下错误:
SyntaxError: /.../app/models/tableposition.rb:4: 语法错误,意外 '\n',期待 tASSOC
我在网上搜索了解决方案,并尝试将花括号转换为 do ... 以括号结尾,但无济于事。任何想法将不胜感激。
【问题讨论】:
标签: ruby-on-rails