OSDN Git Service
(root)
/
tdcgexplorer
/
nimono.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
4cdbcfe981c58d9f81a2ecbdac80704da31a2488
[tdcgexplorer/nimono.git]
/
app
/
models
/
arc.rb
1
class Arc < ActiveRecord::Base
2
belongs_to :location
3
4
class Search
5
attr_accessor :text
6
7
def initialize(attributes)
8
attributes.each do |name, value|
9
send("#{name}=", value)
10
end if attributes
11
end
12
13
def conditions
14
@conditions ||= begin
15
sql = "TRUE"
16
ret = [ sql ]
17
terms = []
18
unless text.blank?
19
sql.concat " and (code like ? or summary like ? or origname like ?)"
20
ret.push "%#{text}%"
21
ret.push "%#{text}%"
22
ret.push "%#{text}%"
23
end
24
ret
25
end
26
end
27
28
def find_options
29
{ :conditions => conditions }
30
end
31
end
32
end