开发者

How can I autocomplete unique values from a list in Ruby on Rails 3?

I'd like each ne开发者_如何学运维w title record in my application to have an ISBN field which autocompletes, using values from a table (I can import a CSV file). The trick is that each new autocompletion needs to use a unique ISBN.


In your model, use validates_uniqueness_of :isbn

Andy raises some good questions though!


If you already have the ISBN values in a table, and the ISBN is a key field (which it certainly should be, since ISBNs are unique?) then really you're not creating a new record, are you?

Wouldn't it be better to read your CSV file into your table beforehand, creating records for each of the ISBNs, and have your app update these records, rather than create new ones?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜