关于提交我的表单抛出错误parameterMissing,我看我的路线和创建是显示注册,我也尝试使用new_signup中从这两个都不似乎固定错误。我不明白为什么这不起作用,并搜索其他帖子找出它,但无济于事。ActionController :: ParameterMissing in SignupsController#create
完全错误
的ActionController :: ParameterMissing在SignupsController#创建
参数是丢失或为空值:注册
private
def signup_params
params.require(:signup).permit(:email)
end
end
服务器日志
Started POST "/signups" for 50.17.182.190 at 2016-01-17 22:06:10 +0000
Cannot render console from 50.17.182.190! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by SignupsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"qteb42ekyyISXRfxX/aJEq6msi5nywvHb/vx0aTBkhLZ61hUutdgrRGP7QK6Jd2jxEesTBANQ9FiXGTLhX7crA=="}
Completed 400 Bad Request in 70ms
ActionController::ParameterMissing (param is missing or the value is empty: signup):
app/controllers/signups_controller.rb:18:in `signup_params'
app/controllers/signups_controller.rb:7:in `create'
这里我的表格
条<%= form_for(@signup, html: { class: 'form-inline' }) do |f| %>
<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="signups">Email address</label>
<input type="email" class="form-control" id="signups" placeholder="Enter email">
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
<% end %>
控制器
class SignupsController < ApplicationController
def new
@signup = Signup.new
end
def create
@signup = Signup.new(signup_params)
if @signup.save
redirect_to root_url, notice: "Thank you for expressing interest."
else
render action: 'new', alert: "Signup failed."
end
end
private
def signup_params
params.require(:signup).permit(:email)
end
end
路线
root GET/ signups#new
signups POST /signups(.:format) signups#create
new_signup GET /signups/new(.:format) signups#new
courses GET /courses(.:format) courses#index
POST /courses(.:format) courses#create
new_course GET /courses/new(.:format) courses#new
如果您发布的实际全文这将有助于错误信息。 – MarsAtomic
我只是发布它。 – user3905353
看起来你正在复制你的'form'标签。 Rails的'form_for'为你创建了一个'form'标记,但是你也在下一行有一个手动的'form'标签:'
',这应该解决您的问题。 另外,始终缩进!这会让阅读你的表格变得更容易。 – dwenzel