Ruby on rails path helpers

后端 未结 2 1974
耶瑟儿~
耶瑟儿~ 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.

    0 讨论(0)
  • 2021-02-15 06:47

    One way to check your routes and paths is to run:

    rake routes
    

    It outputs all your routes and paths.

    0 讨论(0)
提交回复
热议问题