rubyisbeautiful / resource_helper

Lots of helpers and stuff for making ActiveResource more robust, friendly and ActiveRecord-like

This URL has Read+Write access

resource_helper / README
e587c246 » rubyisbeautiful 2008-08-23 initial import 1 ResourceHelper
2 ==============
3
6166ab70 » rubyisbeautiful 2008-08-23 update to README with short... 4 Helpers for using ActiveResource
e587c246 » rubyisbeautiful 2008-08-23 initial import 5
6166ab70 » rubyisbeautiful 2008-08-23 update to README with short... 6 In this gem/plugin and documentation, I refer to the notion of client/server or front/back end. Regardless of your architecture,
7 whatever is using a model as an ActiveRecord is the server or backend, and whatever is using it as an ActiveResource is
8 the client or frontend.
e587c246 » rubyisbeautiful 2008-08-23 initial import 9
10 Example
11 =======
12
6166ab70 » rubyisbeautiful 2008-08-23 update to README with short... 13 Backend stuff
14 ----------------------------
15 # controller will redir to a callback tag if present, otherwise render whatever
16 callback and render :xml => @foo.to_xml
17 # basic actions necessary for well-behaved resource server
18 -- XML index view on every controller
19 index
20 -- return a new, blank instance in XML
21 new
22 -- support method for using ActiveResource::count
23 count
24
25
26 Frontend stuff
27 ----------------------------
28 # ActiveResource Foo
29 Foo.count # -> 2
30
31 # ActiveResource Foo
32 Foo.generate -> a new Foo instance
33
34 # generates a tag for callback, for forms
35 %= index_callback_tag(Foo)
36 when used with callback on the backend, forms will "come back" to the frontend
37
38 # generates a blank associated ActiveResource instead of raising an error on a nil association
39 # ActiveResource::method_missing_with_recover_nil_association
40 before: @foo.bar -> raises error, frontend has no idea what a "bar" is if none is provided
41 after: @foo.bar -> even if no bar is associated, will return a blank instance
e587c246 » rubyisbeautiful 2008-08-23 initial import 42
6166ab70 » rubyisbeautiful 2008-08-23 update to README with short... 43 # useful URL generators for ActiveResource
44 Foo.plural_url -> http://example.com/foos.xml
45 Foo.singular_url(1) -> http://example.com/foo/1
e587c246 » rubyisbeautiful 2008-08-23 initial import 46
6166ab70 » rubyisbeautiful 2008-08-23 update to README with short... 47
48
49 Copyright (c) 2008 [Bryan Taylor], released under the MIT license
50
51 see more at http://rubyisbeautiful.com