xHire-activerecord-tableless 0.1.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/CHANGELOG +7 -0
- data/README +38 -0
- metadata +66 -0
data/CHANGELOG
ADDED
data/README
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
ActiveRecord Tableless
|
2
|
+
----------------------
|
3
|
+
|
4
|
+
A single implementation of the ActiveRecord Tableless pattern for any Rails
|
5
|
+
project or other Ruby project that uses ActiveRecord.
|
6
|
+
|
7
|
+
Define a model like this:
|
8
|
+
|
9
|
+
class ContactMessage < ActiveRecord::Base
|
10
|
+
has_no_table
|
11
|
+
column :name, :string
|
12
|
+
column :email, :string
|
13
|
+
validates_presence_of :name, :email
|
14
|
+
end
|
15
|
+
|
16
|
+
You can now use the model in a view like this:
|
17
|
+
|
18
|
+
<%= form_for :message, @message do |f| %>
|
19
|
+
Your name: <%= f.text_field :name %>
|
20
|
+
Your email: <%= f.text_field :email %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
And in the controller:
|
24
|
+
|
25
|
+
def message
|
26
|
+
@message = ContactMessage.new
|
27
|
+
if request.post?
|
28
|
+
@message.attributes = params[:message]
|
29
|
+
if @message.valid?
|
30
|
+
# Process the message...
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Credits
|
36
|
+
-------
|
37
|
+
Michal Zima <xhire@tuxportal.cz>
|
38
|
+
Kenneth Kalmer <kenneth.kalmer@gmail.com> (original author)
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xHire-activerecord-tableless
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michal Zima
|
8
|
+
- Kenneth Kalmer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-05-16 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: activerecord
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
description: ActiveRecord Tableless provides a simple mixin for creating models that are not bound to the database. This approach is mostly useful for capitalizing on the features ActiveRecord::Validation
|
27
|
+
email: xhire@mujmalysvet.cz
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README
|
34
|
+
- CHANGELOG
|
35
|
+
files:
|
36
|
+
- README
|
37
|
+
- CHANGELOG
|
38
|
+
has_rdoc: true
|
39
|
+
homepage:
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --main
|
43
|
+
- README
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.2.0
|
62
|
+
signing_key:
|
63
|
+
specification_version: 2
|
64
|
+
summary: A library for implementing tableless ActiveRecord models
|
65
|
+
test_files: []
|
66
|
+
|