How to prepopulate form with data passed from @object?

后端 未结 2 1464
天命终不由人
天命终不由人 2021-01-23 06:38

On my website a user can upload \"inspirations\" aka images or text that a user finds inspirational.

I want to create a feature, like Pinterest, where a user ca

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-23 07:13

    You should assign this object in your controller action, something like this:

    def new
      @inspiration = Inspiration.find(params[:inspiration_id])
    end
    

    And the path should be:

    new_inspiration_path(inspiration_id: inspiration.id)
    

提交回复
热议问题