I am new to Rails and I am using the salesforce gem, databasedotcom so there are is no model where I would normally validate the email address format, simple_form is validating presence but this error when an invalid email is entered:
Databasedotcom::SalesForceError at /leads
Email: invalid email address:def create
Here is the controller:
def create
@lead = Lead.new(params[:lead])
@lead['OwnerId'] = '005b0000000WxqE'
if @lead.save
redirect_to @event
else
render "new"
end
end
Here is the form:
<%= simple_form_for @lead, url: leads_path(@lead, event_id: params[:event_id]), method: :post do |f| %>
<%= f.input :FirstName, :label => "First Name" %>
<%= f.input :LastName, :label => "Last Name" %>
<%= f.input :Email %>
<%= f.input :Company %>
<%= f.button :submit, value: "Submit" %>
<% end %>
I need to add something like 'if @lead.valid?' but im not sure what steps to take to make this work because that on its own doesn't work.