-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathREADME
61 lines (42 loc) · 1.96 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
ActiveDirect is a server-side implementation of Ext.Direct Spec (http://www.extjs.com/products/extjs/direct.php
) using Rack Middleware.
Introduction: http://bit.ly/3LkYpB
Features :
12 CRUD related methods directable by default
Custom methods can be added using declarations.
Form and Form upload handler support
Install : script/plugin install [email protected]:stonegao/active-direct.git
Configuration :
* Middleware configurations (environment.rb) :
config.middleware.use 'ActiveDirect::Router', '/direct_router'
config.middleware.use 'ActiveDirect::Api', '/direct_api', '/direct_router’
* In your Html files :
<script type="text/javascript" src=”/javascripts/ext/adapter/ext/ext-base.js"></script>
<script type=“text/javascript” src=”/javascripts/ext/ext-all-debug.js"></script>
<script type=“text/javascript” src=”/direct_api"></script>
* Add rpc provider (in you javascript) :
Ext.Direct.addProvider(REMOTING_API);
* Model configurations
class Category < ActiveRecord::Base
acts_as_direct :root_nodes => 0, :create_new_cat => {:len => 1, :formHandler => true}
def root_nodes
end
def create_new_cat(params)
end
end
Examples ( After config correctly, you can write the following code in Javascript)
App.models.Category.create( { name : ‘ruby’ } )
App.models.Category.update(2, { name : ‘ruby books’ } )
App.models.Category.update_all({ name : ‘ruby books’ }, “ name LIKE ‘%ruby%’ ” )
App.models.Category.all()
App.models.Category.find( 2 )
App.models.Category.find_every( { conditions : “name LIKE ‘%java%’ “ } )
App.models.Category.exists( [“ name LIKE ? “, ‘%java%’ ] )
App.models.Category.first()
App.models.Category.last()
App.models.Category.count()
App.models.Category.delete( 2 )
App.models.Category.delete_all( “ name LIKE ‘%java%’ “ )
To Do :
Add more tests.
Stone Gao (stones.gao at gmail.com), released under the MIT license