[英]Rails controller isn't getting specific params
I'm trying to follow wicked tutorial for creating an object partially ( https://github.com/zombocom/wicked/wiki/Building-Partial-Objects-Step-by-Step )我正在尝试按照邪恶的教程部分创建 object ( https://github.com/zombocom/wicked/wiki/Building-Partial-Objects-Step-by-Step )
The problem is, I am having trouble creating the object itself.问题是,我无法创建 object 本身。 I've tried with and without strong params, or even making the call out of the controller, but can get it passed.
我尝试过使用和不使用强参数,甚至从 controller 进行调用,但可以通过。 What am I doing wrong?
我究竟做错了什么?
class ProspectsController < ApplicationController
include Wicked::Wizard
steps :signup, :business_details, :user_details
def show
create_prospect if params[:prospect_id].nil?
byebug # => prospect_id is no appearing => Not_found
@prospect = Prospect.find(params[:prospect_id])
render_wizard
end
def update
@prospect = Prospect.find(params[:prospect_id])
params[:prospect][:status] = 'users_detailed' if step == steps.last
@prospect.update_attributes(params[:prospect])
render_wizard @prospect
end
def create_prospect
@prospect = Prospect.create
new_prospect_build_path(prospect_id: @prospect.id)
end
# def prospect_params
# params.require(:prospect).
# permit(:user_first_name, :user_last_name, :user_email, :dni, :plan, :empresa_name, :empresa_email,
# :empresa_phone, :empresa_address, :empresa_web, :empresa_category, :empresa_summary, :user_birthday,
# :user_phone, :user_address, :sex, :iban_code, :status, :prospect_id)
# end
end
Routes:路线:
resources :prospects, only: [:show, :update] do
resources :build, controller: 'prospects'
end
you're using same controller action for two routes:您对两条路线使用相同的 controller 操作:
GET /prospects/:prospect_id/build/:id => prospects#show
GET /prospects/:id => prospects#show
same with update.与更新相同。 If you will get to that controller by
GET prospect_path
you will not get :prospect_id
, but :id
.如果您通过
GET prospect_path
路径到达 controller ,您将不会获得:prospect_id
,而是:id
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.