简单记下使用步骤
1. install
script/plugin install auto_complete
2. 直接在controller中加入
class CaseController <>
auto_complete_for :case, :name
view中加入
<%= text_field_with_auto_complete :case, :name %>
3. 基本完成,不过reload page之后发现会有ActionController::InvalidAuthenticityToken之类的error message. 原因是If a request comes in that doesn’t match the request forgery protection token for the current session then an
ActionController::InvalidAuthenticityToken
exception will be thrown. 参考这篇文档,可以绕开.最冲动的办法就是:在application.rb中加入
self.allow_forgery_protection = false
没有评论:
发表评论