ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2009年4月21日 星期二
ultrasphinx has_many, belongs_to 的建法
[分享]Rails中ultrasphinx全文檢索的使用(對象間關聯的處理)
深入探索:Windows+Rails+Sphinx進行中文全文檢索
belongs_to 的時候用 include
<br /> class Press < ActiveRecord::Base<br /> has_many :books<br /> end<br /><br /> class Book < ActiveRecord::Base<br /> belongs_to :press<br /> is_indexed :fields=>[:title],<br /> :include=>[{:association_name=>'press' , :field=>'name' , :as=>'press_name }]<br /> end<br />
has_many 的時候用concatenat
<br /> class Info < ActiveRecord::Base<br /> belongs_to :book<br /> end<br /><br /> class Book < ActiveRecord::Base<br /> has_many :infos<br /> is_indexed :fields=>[:title],<br /> :concatenate => [{:association_name=>'infos' , :field=>'content' , :as=>'content'}]<br /> end<br />
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言