Rails 4错误:从URL获取参数

时间:2016-09-13 11:08:58

标签: ruby-on-rails ruby ruby-on-rails-4 url rubygems

我对rails很新,我正在努力从这个url中获取id param:

http://localhost:3000/subscriberjobs/new?job_id=13

Userflow:

  1. 表单设置作业(下面/作业模型)=>

    redirect_to "/subscriberjobs/new?job_id=#{@job.id}"
    
  2. (工作控制器)=>通过条纹获得付款
  3. (Subscriberjobs Controller)=>更新此作业的值。
  4. 最后一步不起作用。一方面,它总是重定向到/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
    

    非常感谢有关如何实现我想要做的任何帮助!

0 个答案:

没有答案