Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 36 lines (26 sloc) 0.759 kB
1e1aa8d Release candidate for 0.1, rough around the edges
Kenneth Kalmer authored
1 ActiveRecord Tableless Models
2 -----------------------------
3
4 A single implementation of the ActiveRecord Tableless Model pattern for any
5 Rails project or other Ruby project that uses ActiveRecord.
6
27c703e @skamithi add some details to the README from the authors website
authored
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
Something went wrong with that request. Please try again.