I have the below form which works absolute fine but when submitted the :event field returns an ID in the mailer, any ideas how to prevent this?
<%= simple_form_for @sponsorship_inquiry, :method => :post do |f| %>
<%= f.input :spam, as: :hidden %>
<%= f.input :name %>
<%= f.input :phone %>
<%= f.input :email %>
<%= f.input :job_title %>
<%= f.input :company %>
<%= f.input :event, :collection => Event.where(:end_date.gt => Date.today, :is_live => 'true') %>
<%= f.input :message, as: :text, :input_html => { :cols => 5, :rows => 6 } %>
<%= f.button :submit %>
<% end %>
Name: <%= @sponsorship_inquiry.name %>
Phone: <%= @sponsorship_inquiry.name %>
E-Mail: <%= @sponsorship_inquiry.email %>
Job Title: <%= @sponsorship_inquiry.job_title %>
Company: <%= @sponsorship_inquiry.company %>
Event: <%= @sponsorship_inquiry.event %>
Message: <%= @sponsorship_inquiry.message %>
def new
@sponsorship_inquiry = SponsorshipInquiry.new
end
def create
# Hidden field for bots/spiders
redirect_to new_inquiry_path and return if params[:spam].present?
@sponsorship_inquiry = SponsorshipInquiry.new(params[:sponsorship_inquiry])
if @sponsorship_inquiry.valid?
SponsorshipInquiryMailer.admin(@sponsorship_inquiry).deliver
redirect_to sponsorship_inquiries_path
else
render :new
end
end
Need your SponsorshipInquiry model.
If you have
class SponsorshipInquiry < ActiveRecord::Base
belongs_to :event
end
try send <%= @sponsorship_inquiry.event.name %>
or whatever )
Or you need to parse needed value from the form if "event" is only field not associated with Event model.
IMHO