Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 轨道嵌套路线_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 3 轨道嵌套路线

Ruby on rails 3 轨道嵌套路线,ruby-on-rails-3,Ruby On Rails 3,我正在Rails 3.1中创建一个商店应用程序,我有产品和类别模型。类别模型有一个名称属性,该属性包含服装、艺术品和工艺品等值 我希望用户能够使用此路径访问按类别筛选的产品www.example.com/products/toughts,但我不确定如何设置routes.rb文件来实现这一点。棘手的部分是,当涉及到带有空格的类别名称时(如Arts and Crafts),是否有办法使其看起来像www.example.com/products/Arts-and-Crafts 谢谢 你试图用一个问题覆

我正在Rails 3.1中创建一个商店应用程序,我有产品和类别模型。类别模型有一个名称属性,该属性包含服装、艺术品和工艺品等值

我希望用户能够使用此路径访问按类别筛选的产品www.example.com/products/toughts,但我不确定如何设置routes.rb文件来实现这一点。棘手的部分是,当涉及到带有空格的类别名称时(如Arts and Crafts),是否有办法使其看起来像www.example.com/products/Arts-and-Crafts


谢谢

你试图用一个问题覆盖相当多的领域

考虑阅读,特别是关于足智多谋路线的部分


从使用最简单的默认路由开始,它看起来像“/categories/123”,这样就可以工作了。然后再回来问另一个问题。:)

要解决带有空格的类别名称问题,您可能需要使用gem。