Ruby on rails path helpers

后端 未结 2 1967
耶瑟儿~
耶瑟儿~ 2021-02-15 06:01

I know this is a minor issue, but why, if you use scaffolding in RoR, can you use lines like \'new_model name here_path\' in link tags, but without using scaffolding, I

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-15 06:27

    Scaffolding sets up resource routes in the routes.rb file. The resource routes are what give you the path and url helpers. When you don't use scaffolding the routes aren't added, you must do it by hand.

    Resource Routes can be added like so:

    map.resources :models
    

    where :models is the plural name of one of your models.

提交回复
热议问题