programmable-rc_actions 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +7 -0
- data/lib/rc_actions/actions.rb +33 -0
- data/lib/rc_actions/common_actions.rb +88 -0
- data/lib/rc_actions.rb +5 -0
- metadata +71 -0
data/README
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Programmable
|
2
|
+
module ResourceController
|
3
|
+
module Actions
|
4
|
+
include Programmable::ResourceController::CommonActions
|
5
|
+
|
6
|
+
declarations do
|
7
|
+
before_filter :assign_new_resource, :only => [:new, :create]
|
8
|
+
before_filter :assign_find_resource, :only => [:show, :edit, :update, :destroy]
|
9
|
+
before_filter :assign_find_resources, :only => [:index]
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module SingletonActions
|
17
|
+
include Programmable::ResourceController::CommonActions
|
18
|
+
|
19
|
+
declarations do
|
20
|
+
before_filter :assign_new_resource, :only => [:new, :create]
|
21
|
+
before_filter :assign_find_resource, :only => [:show, :edit, :update, :destroy]
|
22
|
+
end
|
23
|
+
|
24
|
+
def after_destroy_url
|
25
|
+
if enclosing_resource
|
26
|
+
enclosing_resource_path
|
27
|
+
else
|
28
|
+
root_path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Programmable
|
2
|
+
module ResourceController
|
3
|
+
module CommonActions
|
4
|
+
def show
|
5
|
+
end
|
6
|
+
|
7
|
+
def new
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@resource_saved = resource.save
|
12
|
+
response_for_create
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
end
|
17
|
+
|
18
|
+
def update
|
19
|
+
@resource_saved = resource.update_attributes params[resource_name]
|
20
|
+
response_for_update
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy
|
24
|
+
response_for_destroy resource.destroy
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def response_for_create
|
30
|
+
if @resource_saved
|
31
|
+
flash[:notice] = "#{resource_name.humanize} was successfully created."
|
32
|
+
redirect_to after_create_url
|
33
|
+
else
|
34
|
+
render :action => "new"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def response_for_update
|
39
|
+
if @resource_saved
|
40
|
+
flash[:notice] = "#{resource_name.humanize} was successfully updated."
|
41
|
+
redirect_to after_update_url
|
42
|
+
else
|
43
|
+
render :action => "edit"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def response_for_destroy status
|
48
|
+
if status
|
49
|
+
flash[:notice] = "#{resource_name.humanize} was successfully deleted."
|
50
|
+
else
|
51
|
+
flash[:notice] = "#{resource_name.humanize} can't be deleted."
|
52
|
+
end
|
53
|
+
redirect_to after_destroy_url
|
54
|
+
end
|
55
|
+
|
56
|
+
def after_create_url
|
57
|
+
resource_path
|
58
|
+
end
|
59
|
+
|
60
|
+
def after_update_url
|
61
|
+
resource_path
|
62
|
+
end
|
63
|
+
|
64
|
+
def after_destroy_url
|
65
|
+
resources_path
|
66
|
+
end
|
67
|
+
|
68
|
+
def response_for_ajax
|
69
|
+
respond_to do |format|
|
70
|
+
format.html { redirect_to :back }
|
71
|
+
format.js
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def assign_new_resource
|
76
|
+
self.resource = new_resource
|
77
|
+
end
|
78
|
+
|
79
|
+
def assign_find_resource
|
80
|
+
self.resource = find_resource
|
81
|
+
end
|
82
|
+
|
83
|
+
def assign_find_resources
|
84
|
+
self.resources = find_resources
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/rc_actions.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: programmable-rc_actions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilia Ablamonov
|
8
|
+
- Artem Orlov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-04-28 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rails
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.3.2
|
25
|
+
version:
|
26
|
+
description: Better actions for resources_controller plugin.
|
27
|
+
email: pro@grammable.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- README
|
36
|
+
- lib/rc_actions
|
37
|
+
- lib/rc_actions/actions.rb
|
38
|
+
- lib/rc_actions/common_actions.rb
|
39
|
+
- lib/rc_actions.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/programmable/rc_actions
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --quiet
|
45
|
+
- --main
|
46
|
+
- README
|
47
|
+
- --inline-source
|
48
|
+
- --charset=UTF-8
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.2
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.2.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: Better actions for resources_controller plugin.
|
70
|
+
test_files: []
|
71
|
+
|