新手问题 使用 Ransack 遇到的问题

caomei777 · 2015年12月14日 · 最后由 caomei777 回复于 2015年12月15日 · 1885 次阅读

[3] pry(#<#Class:0x007f79acbfee38>)> exit CACHE (0.0ms) SELECT "key_word_lists".* FROM "key_word_lists" WHERE ("key_word_lists"."value_cn" LIKE '%阿迪达斯%') LIMIT 30 OFFSET 0 Rendered key_word_lists/single_store_key_word_lists.html.erb within layouts/application (131944.2ms) Completed 500 Internal Server Error in 146479ms (ActiveRecord: 0.6ms)

ActionView::Template::Error (Association named 'value_cn' was not found on KeyWordLists::BrandKeyWordList; perhaps you misspelled it?):

哪位大神能帮忙看一下这段调试: SELECT "key_word_lists".* FROM "key_word_lists" WHERE ("key_word_lists"."value_cn" LIKE '%阿迪达斯%') LIMIT 30 OFFSET 0 从数据库查询是可以查询出结果来的,为什么下面会报 'ActionView::Template::Error (Association named 'value_cn' was not found on KeyWordLists::BrandKeyWordList; perhaps you misspelled it?))'这种错误呢

Association named 'value_cn'你是不是把字段名当作 association 名字用了啊?!

[3] pry(#<#Class:0x007f79acbfee38>)> exit
CACHE (0.0ms) SELECT "key_word_lists".* FROM "key_word_lists" WHERE ("key_word_lists"."value_cn" LIKE '%阿迪达斯%') LIMIT 30 OFFSET 0
Rendered key_word_lists/single_store_key_word_lists.html.erb within layouts/application (131944.2ms)
Completed 500 Internal Server Error in 146479ms (ActiveRecord: 0.6ms)

ActionView::Template::Error (Association named 'value_cn' was not found on KeyWordLists::BrandKeyWordList; perhaps you misspelled it?):

哪位大神能帮忙看一下这段调试:

SELECT "key_word_lists".* FROM "key_word_lists" WHERE ("key_word_lists"."value_cn" LIKE '%阿迪达斯%') LIMIT 30 OFFSET 0

从数据库查询是可以查询出结果来的,为什么下面会报

'ActionView::Template::Error (Association named 'value_cn' was not found on KeyWordLists::BrandKeyWordList; perhaps you misspelled it?))'

这种错误呢

嗯 是呢 已解决 谢谢大神

需要 登录 后方可回复, 如果你还没有账号请 注册新账号