Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Commit

Permalink
Merge pull request #144 from coeventer/142_event_contact
Browse files Browse the repository at this point in the history
Add event as option for contact form
  • Loading branch information
pete2786 committed Feb 28, 2017
2 parents 6bccf4a + 1517f82 commit dffd080
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 8 additions & 2 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Message
include ActiveModel::Conversion
extend ActiveModel::Naming

attr_accessor :name, :email, :subject, :body
attr_accessor :name, :email, :subject, :body, :event

validates :name, :email, :subject, :body, :presence => true
validates :email, :format => { :with => %r{.+@.+\..+} }, :allow_blank => true
Expand All @@ -19,4 +19,10 @@ def persisted?
false
end

end
def event_title
return "None" unless event

Event.find_by(id: event).try(:title) || "None"
end

end
3 changes: 2 additions & 1 deletion app/views/contact/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<div class="hr light extra-margin"><hr></div>
<%= semantic_form_for @message, :url => contact_path do |f| %>
<%= f.input :name, :input_html => { :class => 'span5'} %>
<%= f.input :event, as: :select, collection: Event.live%>
<%= f.input :email, :input_html => { :class => 'span5'} %>
<%= f.input :subject, :input_html => { :class => 'span5'} %>
<%= f.input :body, :label => "Comment or Question", :as => :text, :input_html => { :class => 'span5'} %>
Expand All @@ -13,4 +14,4 @@
<% end %>
</div>

</div><!--/end main container -->
</div><!--/end main container -->
4 changes: 3 additions & 1 deletion app/views/contact_mailer/contact_admins.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Name: <%= @message.name %>

Email: <%= @message.email %>

<%= @message.body %>
Event: <%= @message.event_title %>
<%= @message.body %>

0 comments on commit dffd080

Please sign in to comment.