Skip to content

Commit a74ea11

Browse files
committed
doh, apparently i need that Message model for the contact form ...whooops
1 parent 8f26b05 commit a74ea11

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

app/models/message.rb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Message #< ActiveRecord::Base
2+
3+
# include ActiveAttr::Model
4+
5+
# attribute :name
6+
# attribute :subject
7+
# attribute :content
8+
9+
# validates_presence_of :name
10+
# validates_presence_of :subject
11+
# validates_length_of :content, :maximum => 500
12+
13+
include ActiveModel::Validations
14+
include ActiveModel::Conversion
15+
extend ActiveModel::Naming
16+
17+
attr_accessor :name, :email, :subject, :body
18+
19+
validates :name, :email, :subject, :body, :presence => true
20+
validates :email, :format => { :with => %r{.+@.+\..+} }, :allow_blank => true
21+
22+
def initialize(attributes = {})
23+
attributes.each do |name, value|
24+
send("#{name}=", value)
25+
end
26+
end
27+
28+
def persisted?
29+
false
30+
end
31+
end

app/views/contact/index.html.erb

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
<div id="contact_form">
22

33
<h1>Contact Me :)</h1>
4+
<h6>index.html.erb</h6>
45

56
<%= form_for Message.new, :url => contact_path do |f| %>
67

78
<!-- name -->
89
<div class="field">
910
<%= f.text_field :name, :class => 'input-xlarge', placeholder: 'name' %>
1011
</div>
11-
1212
<!-- email -->
1313
<div class="field">
1414
<%= f.text_field :email, :class => 'input-xlarge', placeholder: 'email' %>
1515
</div>
16-
1716
<!-- subject -->
1817
<div class="field">
1918
<%= f.text_field :subject, :class => 'input-xlarge', placeholder: 'Subject' %>
2019
</div>
21-
2220
<!-- message -->
2321
<div class="field">
2422
<%= f.text_area :body, :rows => 10, :cols => 50, placeholder: 'Enter a short synopsis'%>
2523
</div>
26-
2724
<!-- submit -->
2825
<div class="actions"><%= f.submit "Send Message", :class => 'btn btn-xlarge btn-custom'%>
2926
</div>
30-
3127
<% end %>
32-
33-
3428
</div>

0 commit comments

Comments
 (0)