简体   繁体   English

使用Databasedotcom-rails gem从RoR应用程序创建Salesforce自定义对象记录时出现NoMethodError

[英]NoMethodError when creating a Salesforce custom object record from a RoR app with databasedotcom-rails gem

I have a custom object in Salesforce called Sales__c. 我在Salesforce中有一个名为Sales__c的自定义对象。 I am trying to create a record from a RoR app using the databasedotcom-rails gem. 我正在尝试使用databasedotcom-rails gem从RoR应用程序创建记录。

Controller 控制者

Class SalesController < ApplicationController
include Databasedotcom::Rails::Controller

  def new
    @sale = Sale__c.new
  end

  def create
    sale = Sale__c.new(params[:sale])

    sale.Item_on_Machine__c = "a0Co0000001TszL"
    sale.OwnerId = "005o0000000HLctAAG"

    if @sale.save
        redirect_to(sale, :notice => 'Sale was successfully created.')
    end

   end


end

View 视图

<h1>New Sale</h1>
<div class="actions">
    <%= f.submit %>
</div>

#Note there is no field on the form, just the submit button. #注意表单上没有字段,只有提交按钮。

Routes 路线

VendingForce2::Application.routes.draw do
  resources :sales
end

//////////////////////// ERROR ///////////////////////错误

When I go to 当我去

http://0.0.0.0:3000/sales/new 

I get the following error 我收到以下错误

NoMethodError in Sales#new

undefined method `sale__cs_path' for #<#<Class:0x007f85cc7c79d8>:0x007f85cc7c4dc8>

app/views/sales/new.html.erb:4:in `_app_views_sales_new_html_erb___1324507284181611345_70106319051940'

Any idea? 任何想法?

Try having the <%= f.submit %> under a for tag: 尝试将<%= f.submit%>放在for标记下:

<% @sale.each do |f| %>
<%= f.submit %>
<% end %>

Or 要么

try this 尝试这个

<%= form_for @sale do |f| %>
  <%= f.submit %>
<% end %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM