Ruby on rails 参数数量错误(1代表0)-对我来说没有意义
在提交新提案的表格时,我遇到了这个错误。我不明白为什么 ProposalsController#create中的ArgumentError 参数数目错误(1代表0)Ruby on rails 参数数量错误(1代表0)-对我来说没有意义,ruby-on-rails,Ruby On Rails,在提交新提案的表格时,我遇到了这个错误。我不明白为什么 ProposalsController#create中的ArgumentError 参数数目错误(1代表0) 控制器: class ProposalsController < ApplicationController def new @proposal = Proposal.new end def create @proposal = Proposal.new(
控制器:
class ProposalsController < ApplicationController
def new
@proposal = Proposal.new
end
def create
@proposal = Proposal.new(prop_params)
@proposal.save
# if @proposal.save
# redirect_to proposal_path(params[:proposal][:id])
# else render 'new'
# end
end
def show
@proposal = Proposal.find(params[:id])
end
def index
@proposals = Proposal.all
end
def prop_params
params.require(:proposal).permit(:content, :title)
end
end
class ProposalsController
新观点:
<div class="pform">
<%= form_for @proposal do |f| %>
<%= f.label :title, 'Titlu' %><br />
<%= f.text_field :title %><br />
<%= f.label :content, 'Conţinut' %><br />
<%= f.text_area :content %> <br />
<%= f.submit, 'Trimite' %>
<% end %>
</div>
提案迁移模型
class CreateProposals < ActiveRecord::Migration
def change
create_table :proposals do |t|
t.string :title
t.string :content
t.timestamps null: false
end
end
end
class CreatePropositions
请发布完整的错误消息和堆栈跟踪,包括文件名和行号。这闻起来像是Rails 4.2最近常见的Arel问题。将gem'arel',6.0.0.beta2'
添加到您的Gemfile.+“提取的源代码(第0行附近):“完整跟踪:我已经安装了arel gem 6.0.0.beta2-没有它,我无法运行db:migrate。