public
Fork of moro/search_do
Description: AR: Hyperestraier integration
Homepage:
Clone URL: git://github.com/grosser/search_do.git
grosser (author)
Sat Jan 17 00:49:59 -0800 2009
commit  ca31ae6215d74cde1f05c1a9f7f6d391022924cd
tree    47921598bd2f06efb0165d358d3760dc7fdcd3f5
parent  34eaaa29aac7643a51a769bcc503c58fd0c43b64
search_do / spec / setup_test_model.rb
100755 38 lines (32 sloc) 0.923 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'rubygems'
require 'active_record'
require 'active_record/fixtures'
 
#activate will_paginate for models
require 'will_paginate'
WillPaginate.enable_activerecord
 
#create model table
ActiveRecord::Schema.define(:version => 1) do
  create_table "stories" do |t|
    t.date "written_on"
    t.datetime "read_at"
    t.string "title"
    t.text "body"
    t.integer "popularity", :default =>0
    t.timestamps
  end
end
 
#create model
class Story < ActiveRecord::Base
  attr_accessor :snippet
  acts_as_searchable :searchable_fields=>[:title, :body],:attributes=>{:non_column=>nil,:body=>nil}
  
  def non_column
    @non_column
  end
  
  def non_column=(val)
    @non_column=val
  end
end
 
#create node
require File.expand_path("../lib/estraier_admin", File.dirname(__FILE__))
admin = EstraierAdmin.new(ActiveRecord::Base.configurations["test"][:estraier])
admin.create_node(Story.search_backend.node_name)