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

caomei777 · December 14, 2015 · Last by caomei777 replied at December 15, 2015 · 1880 hits

[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?))'

这种错误呢

嗯 是呢 已解决 谢谢大神

You need to Sign in before reply, if you don't have an account, please Sign up first.