-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
94 lines (62 loc) · 2.57 KB
/
README
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
CuteAdmin
=========
CuteAdmin is Ruby on Rails plug-in. It is mainly generator,
replacement of classic Ruby on Rails scaffold.
Generated code allows you immediately to use advanced features
such as pagination, ordering, search and i18n translations.
CuteAdmin is based on ActiveRecord extension Searchlogic.
CuteAdmin works fine with Ruby on Rails 2.2 and 2.3.
This is upgraded version for Searchlogic 2.4.x (may work with any 2.x.x version).
Legacy version for Searchlogic 1.6.6 is available in branch searchlogic_1_6_6.
Installation
============
In your rails application folder run:
`./script/plugin install git://github.com/jana4u/cute_admin.git`
CuteAdmin requires Searchlogic. You can use a gem (recommended):
`sudo gem install searchlogic`
Don't forget to add it to config/environment.rb:
config.gem "searchlogic"
Or you can install it as a rails plug-in:
`./script/plugin install git://github.com/binarylogic/searchlogic.git`
If you are running Ruby on Rails prior to 2.3.6
you should install I18nLabel rails plug-in as well:
`./script/plugin install git://github.com/iain/i18n_label.git`
(I18nLabel is not necessary if you don't want to automatically translate labels
for ActiveRecord attributes using I18n.)
Usage
=====
1. generate models
2. run `rake db:migrate` to create database tables for your models
3. set associations (belongs_to, has_many etc.) in your models
4. set acts_as_cute_admin in your models
5. run `rake cute_admin:generate_with_associations`
or you can run generator directly for selected model:
`./script/generate cute_admin Developer --add-associated`
Example
=======
class Country < ActiveRecord::Base
acts_as_cute_admin
has_many :companies
end
class Company < ActiveRecord::Base
acts_as_cute_admin
belongs_to :country
has_many :developers
end
class Developer < ActiveRecord::Base
acts_as_cute_admin :display_name => :full_name
belongs_to :company
named_scope :ascend_by_full_name, { :order => "developers.last_name, developers.first_name" }
named_scope :descend_by_full_name, { :order => "developers.last_name DESC, developers.first_name DESC" }
named_scope :full_name_contains, lambda { |string| { :conditions => [
"(developers.last_name LIKE ? OR developers.first_name LIKE ?)",
"%#{string}%",
"%#{string}%"
] } }
def full_name
"#{last_name}, #{first_name}"
end
end
Source code is available at: http://github.com/jana4u/cute_admin
Source code of sample application is available at: http://github.com/jana4u/cute_admin_example
Copyright (c) 2008 Jana4U <[email protected]>, released under the MIT license