% 不能用作 ActiveRecord default_scope 查询的通配符?
我在 Rails 项目中使用 ActiveRecord,我的一个类如下所示:
class ServerModel < ActiveRecord::Base
set_table_name "S985_947_MODELS_VW"
set_primary_key "model_barcode"
default_scope :conditions => ["FULLNAME like '\/IT INFRASTRUCTURE\/HARDWARE\/SERVER\/PHYSICAL\/%' OR FULLNAME like '\/IT INFRASTRUCTURE\/HARDWARE\/SERVER\/PHYSICAL\/%'"]
acts_as_reportable
acts_as_entity
end
我的 default_scope 方法返回格式错误的格式字符串 - %'
错误。我认为是 %
通配符造成了所有的麻烦。我也尝试过不转义 /
,所以不是这样......
你能帮我吗?
谢谢
I am using ActiveRecord in my Rails project and one of my classes looks like this:
class ServerModel < ActiveRecord::Base
set_table_name "S985_947_MODELS_VW"
set_primary_key "model_barcode"
default_scope :conditions => ["FULLNAME like '\/IT INFRASTRUCTURE\/HARDWARE\/SERVER\/PHYSICAL\/%' OR FULLNAME like '\/IT INFRASTRUCTURE\/HARDWARE\/SERVER\/PHYSICAL\/%'"]
acts_as_reportable
acts_as_entity
end
My default_scope method returns a malformed format string - %'
error. I think it is the %
wildcard that causes all the trouble. I also tried without escaping the /
, so that's not it...
Could you help me?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其更改为:
Change it to: