我对rails很新,我正在努力从这个url中获取id param:
http://localhost:3000/subscriberjobs/new?job_id=13
Userflow:
表单设置作业(下面/作业模型)=>
redirect_to "/subscriberjobs/new?job_id=#{@job.id}"
最后一步不起作用。一方面,它总是重定向到/subscriberjobs/1
,另一方面它不会更新值(对于作业1和作业13都没有)
目前我正在使用此代码来获取它:( Subscriberjobs Controller)
def update
@job = Job.find_by(id: params[:id])
@job.is_active = true
@job.is_featured = false
@job.stripe_id = customer.id
@job.save
token = params[:stripeToken]
customer = Stripe::Customer.create(
card: token,
plan: 1004,
email: current_user.email
)
redirect_to root_path
end
表格:
= simple_form_for @job do |f|
= f.input :company, required: true
= f.input :title, required: true
= f.input :job_filename
= f.input :location, required: true
= f.input :sort
= f.input :tag_list, required: true
= f.input :content_one
= f.input :content_two
= f.input :content_three
= f.hidden_field :job_id, value: params[:id]
= f.button :submit
非常感谢有关如何实现我想要做的任何帮助!