aguids-publishable 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +69 -1
- data/VERSION +1 -1
- data/publishable.gemspec +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,6 +1,74 @@
|
|
1
1
|
= publishable
|
2
2
|
|
3
|
-
|
3
|
+
Rails engine for encapsulating the concept of a publishable resource. Included are:
|
4
|
+
|
5
|
+
* acts_as_publishable extension for models
|
6
|
+
* controller to handle tha publishing and unpublishing of resources complete with routes
|
7
|
+
* helpers for urls and links
|
8
|
+
|
9
|
+
|
10
|
+
== Instalation
|
11
|
+
|
12
|
+
Specify it in your Rails config.
|
13
|
+
|
14
|
+
config.gem 'aguids-publishable', :lib => 'publishable', :source => 'http://gems.github.com'
|
15
|
+
|
16
|
+
Then install it.
|
17
|
+
|
18
|
+
rake gems:install
|
19
|
+
|
20
|
+
|
21
|
+
== Usage
|
22
|
+
|
23
|
+
The first step is to declare a model that acts-as-publishable:
|
24
|
+
|
25
|
+
class ListItem < ActiveRecord::Base
|
26
|
+
acts_as_publishable
|
27
|
+
end
|
28
|
+
|
29
|
+
=== Options
|
30
|
+
|
31
|
+
The default initial state for publishable models is unpublished. To change that just pass the initial state option:
|
32
|
+
|
33
|
+
acts_as_publishable :initial_state => :published
|
34
|
+
|
35
|
+
The status column is the default for storing publish status. If you would like to change jus pass the column option:
|
36
|
+
|
37
|
+
acts_as_publishable :column => :my_fancy_column
|
38
|
+
|
39
|
+
=== Controller
|
40
|
+
|
41
|
+
The publications controller has two actions mapped to it: create and destroy
|
42
|
+
|
43
|
+
:resource/:id/publish #create
|
44
|
+
:resource/:id/unpublish #destroy
|
45
|
+
|
46
|
+
Remember these are restful, so only posts to create and deletes to destroy are accepted.
|
47
|
+
|
48
|
+
If you would like to override the flash messages just define the appropriate translations:
|
49
|
+
|
50
|
+
flash:
|
51
|
+
publications:
|
52
|
+
create:
|
53
|
+
notice: 'New publish message.'
|
54
|
+
destroy:
|
55
|
+
notice: 'New unpublish message.'
|
56
|
+
|
57
|
+
=== Helpers
|
58
|
+
|
59
|
+
Route helpers are available
|
60
|
+
|
61
|
+
publish_path(post) # post/post_id/publish
|
62
|
+
|
63
|
+
Apart from the route helpers we have the following link helpers:
|
64
|
+
|
65
|
+
publication_link(resource) # Either a link to publish or unpublish
|
66
|
+
publication_links(resource) # List with Publish | Unpublish options
|
67
|
+
|
68
|
+
To use the helpers just drop the helper call on the applications controller
|
69
|
+
|
70
|
+
helper :publications
|
71
|
+
|
4
72
|
|
5
73
|
== Copyright
|
6
74
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/publishable.gemspec
CHANGED