Ruby on Rails generates model field:type - what are the options for field:type?

后端 未结 8 1826
遥遥无期
遥遥无期 2020-12-22 15:42

I\'m trying to generate a new model and forget the syntax for referencing another model\'s ID. I\'d look it up myself, but I haven\'t figured out, among all my Ruby on Rails

8条回答
  •  温柔的废话
    2020-12-22 16:06

    I had the same issue, but my code was a little bit different.

    def new
     @project = Project.new
    end
    

    And my form looked like this:

    <%= form_for @project do |f| %>
         and so on....
    <% end %>
    

    That was totally correct, so I didn't know how to figure it out.

    Finally, just adding

    url: { projects: :create }
    
    

    after

    <%= form-for @project ...%>
    
    

    worked for me.

提交回复
热议问题