databasedotcom & databasedotcom-rails gem を使用して、フォームの送信から Salesforce へのリードを生成します。コントローラーを親の下にネストするまでスタンドアロンで動作していましたが、送信を押すと、次のルート エラーが発生します。
No route matches [POST] "/events/516ee9a0421aa9c44e000001/leads/new"
ここにすべての私のコードがあります:
resources :events do
resources :leads
end
class LeadsController < ApplicationController
include Databasedotcom::Rails::Controller
def new
@lead = Lead.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @lead }
end
end
def create
@lead = Lead.new(params[:lead])
@lead.event_id = params[:event_id]
@lead['OwnerId'] = '005b0000000WxqE'
@lead['IsConverted'] = false
@lead['IsUnreadByOwner'] = false
respond_to do |format|
if @event_lead.save
format.html { redirect_to @lead, :notice => 'Lead was successfully created.' }
format.json { render :json => @lead, :status => :created, :location => @lead }
else
format.html { render :action => "new" }
format.json { render :json => @lead.errors, :status => :unprocessable_entity }
end
end
end
end
<%= simple_form_for [@event, @lead], url: new_event_lead_path do |f| %>
<%= f.input :Download_Brochure__c, :check => "true", :as => :boolean, :as => :hidden %>
<%= f.input :FirstName %>
<%= f.input :LastName %>
<%= f.input :Company %>
<p>Also interested in:</p>
<%= f.input :Sponsor_Request__c, :as => :boolean, :label => "Sponsoring" %>
<%= f.input :Presenting__c, :as => :boolean, :label => "Presenting" %>
<%= f.input :Newsletter_Signup__c, :as => :boolean, :label => "Newletter" %>
<%= f.input :Privacy_Policy__c, :as => :boolean, :checked => true, :label => "Would you like to stay updated" %>
<%= f.button :submit, :label => "Submit" %>
<% end %>