0

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.

Dan Mitchell
  • 844
  • 2
  • 15
  • 34

1 Answers1

0

This seems to be an options for you, client_side_validations-simple_form gem has the simple_form with client_side_validation.

hope this helps

sameera207
  • 16,547
  • 19
  • 87
  • 152