railhead_autouser 0.1.3
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/MIT-LICENSE +20 -0
- data/README.rdoc +30 -0
- data/init.rb +1 -0
- data/lib/railhead_autouser.rb +24 -0
- data/railhead_autouser.gemspec +18 -0
- metadata +60 -0
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 [name of plugin creator]
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
= RailheadAutoUser
|
|
2
|
+
|
|
3
|
+
RailheadAutoUser is a Ruby on Rails plugin that automatically adds current_user to models.
|
|
4
|
+
|
|
5
|
+
== Installation
|
|
6
|
+
|
|
7
|
+
Installation is available as gem (recommended):
|
|
8
|
+
|
|
9
|
+
config.gem 'nagybence-railhead_autouser', :lib => 'railhead_autouser', :source => 'http://gems.github.com'
|
|
10
|
+
|
|
11
|
+
Or as Rails plugin:
|
|
12
|
+
|
|
13
|
+
$ ruby script/plugin install git://github.com/nagybence/railhead_autouser.git
|
|
14
|
+
|
|
15
|
+
== Usage
|
|
16
|
+
|
|
17
|
+
Setup user in your migration:
|
|
18
|
+
|
|
19
|
+
create_table :table_name do |f|
|
|
20
|
+
f.references :user
|
|
21
|
+
...
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Add the following line to your controller:
|
|
25
|
+
|
|
26
|
+
auto_user
|
|
27
|
+
|
|
28
|
+
== License
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2008-2009 Bence Nagy (nagybence@tipogral.hu), released under the MIT license.
|
data/init.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'railhead_autouser'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module RailheadAutoUserModel
|
|
2
|
+
def self.included(base)
|
|
3
|
+
base.class_eval do
|
|
4
|
+
add_observer(RailheadAutoUserSweeper.instance)
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
module RailheadAutoUserController
|
|
10
|
+
def auto_user
|
|
11
|
+
class_eval do
|
|
12
|
+
cache_sweeper :railhead_auto_user_sweeper
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class RailheadAutoUserSweeper < ActionController::Caching::Sweeper
|
|
18
|
+
def before_validation(record)
|
|
19
|
+
record.user_id = current_user.id if current_user and record.respond_to?(:user_id) and record.new_record? and record.user_id.nil?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
ActiveRecord::Base.send :include, RailheadAutoUserModel
|
|
24
|
+
ActionController::Base.send :extend, RailheadAutoUserController
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "railhead_autouser"
|
|
3
|
+
s.version = "0.1.3"
|
|
4
|
+
s.date = "2009-01-28"
|
|
5
|
+
s.summary = "RailheadAutoUser is a Ruby on Rails plugin that automatically adds current_user to models."
|
|
6
|
+
s.email = "nagybence@tipogral.hu"
|
|
7
|
+
s.homepage = "http://github.com/nagybence/railhead_autouser"
|
|
8
|
+
s.description = "RailheadAutoUser is a Ruby on Rails plugin that automatically adds current_user to modelsk."
|
|
9
|
+
s.has_rdoc = true
|
|
10
|
+
s.authors = ["Bence Nagy"]
|
|
11
|
+
s.files = ["MIT-LICENSE",
|
|
12
|
+
"README.rdoc",
|
|
13
|
+
"init.rb",
|
|
14
|
+
"railhead_autouser.gemspec",
|
|
15
|
+
"lib/railhead_autouser.rb"]
|
|
16
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
|
17
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
|
18
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: railhead_autouser
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Bence Nagy
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-01-28 00:00:00 +01:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: RailheadAutoUser is a Ruby on Rails plugin that automatically adds current_user to modelsk.
|
|
17
|
+
email: nagybence@tipogral.hu
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- README.rdoc
|
|
24
|
+
files:
|
|
25
|
+
- MIT-LICENSE
|
|
26
|
+
- README.rdoc
|
|
27
|
+
- init.rb
|
|
28
|
+
- railhead_autouser.gemspec
|
|
29
|
+
- lib/railhead_autouser.rb
|
|
30
|
+
has_rdoc: true
|
|
31
|
+
homepage: http://github.com/nagybence/railhead_autouser
|
|
32
|
+
licenses: []
|
|
33
|
+
|
|
34
|
+
post_install_message:
|
|
35
|
+
rdoc_options:
|
|
36
|
+
- --main
|
|
37
|
+
- README.rdoc
|
|
38
|
+
require_paths:
|
|
39
|
+
- lib
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: "0"
|
|
45
|
+
version:
|
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: "0"
|
|
51
|
+
version:
|
|
52
|
+
requirements: []
|
|
53
|
+
|
|
54
|
+
rubyforge_project:
|
|
55
|
+
rubygems_version: 1.3.5
|
|
56
|
+
signing_key:
|
|
57
|
+
specification_version: 3
|
|
58
|
+
summary: RailheadAutoUser is a Ruby on Rails plugin that automatically adds current_user to models.
|
|
59
|
+
test_files: []
|
|
60
|
+
|