關於提交我的表單拋出錯誤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