English 中文(简体)
错误论点数目(2项) (1) 铁路
原标题:wrong number of arguments (2 for 1) - Rails

现在,我真心 st地 st着,并对此感到厌恶。

我正在运行铁路2.3.5。

My View/pages/customers.html.erb 只是:

<% form_tag do %>
    First Name
        <%= text_field_tag :firstName, params[:firstName] %>
    Last Name
        <%= text_field_tag :lastName, params[:lastName] %>

        <%= submit_tag "Enter" %>
<%end%>

My Models/customer.rb 只是:

class Customer < ActiveRecord::Base
    attr_accessible :firstName, :lastName
end

www.un.org/Depts/DGACM/index_spanish.htm ——

class PagesController < ApplicationController
  def custs
    @cust = Customer.new(params[:firstName], params[:lastName])
    @cust.save
  end
end

你们看到,我只是试图从前线进入两个领域,然后将这些领域留给非行。 然而,每当我上页时,我就错了:

wrong number of arguments (2 for 1) pages_controller.rb:3:in new pages_controller.rb:3:incusts

令人痛心的是,当我使用沙箱文字/灯光时,我能够插入数据罚款。

这里正在发生什么? 请有人解释。

最佳回答
问题回答

快速固定装置将改为:3>>s_controller。

@cust = Customer.new({:firstName => params[:firstName], :lastName => params[:lastName]})

没有适当的<条码>钥匙 铁路对你所传递的价值观和秩序没有任何想法。

最大的问题似乎是,你的形式并不恰当。 也许你会有充分理由这样做,但如果没有,我建议设立一个空白铁路项目,并利用<代码>generate scafraft查看如何建立正常的铁路/控制器。

new 采用h法,从中可以确定 has有相应钥匙的特性,Customer.new(params)应当足够? 除非寄生虫还具有你不想在此案中确定的性质的关键,否则我会说。

显然,你的样本代码可能经过编辑,以更好地说明问题,但如上所示,<代码>#new/#save。 乳房通常可以压缩到Customer#create(params)





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签