Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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 是否可以将/folder/sub_folder与RubyonRails中控制器的所有操作相匹配?_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 3.1_Rails Routing - Fatal编程技术网

Ruby on rails 是否可以将/folder/sub_folder与RubyonRails中控制器的所有操作相匹配?

Ruby on rails 是否可以将/folder/sub_folder与RubyonRails中控制器的所有操作相匹配?,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,rails-routing,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,Rails Routing,我有一个相册控制器,但希望该控制器中的所有操作都使用localhost:3000/settings/photo\u gallery/。。。。。。。。。而不是本地主机:3000/。。。。。。。。。我试过导游的建议,但运气不好。有人能帮我吗 我想我可能不得不将相册控制器重命名为照片库 我是单独创建路线的,但必须有一种方法让我一次完成,因为这样会更快 routes.rb scope '/settings/photo_gallery' do resources :photo_albums end

我有一个相册控制器,但希望该控制器中的所有操作都使用localhost:3000/settings/photo\u gallery/。。。。。。。。。而不是本地主机:3000/。。。。。。。。。我试过导游的建议,但运气不好。有人能帮我吗

我想我可能不得不将相册控制器重命名为照片库

我是单独创建路线的,但必须有一种方法让我一次完成,因为这样会更快

routes.rb

  scope '/settings/photo_gallery' do
  resources :photo_albums
end 
耙道:

users GET    /users(.:format)                                        {:action=>"index", :controller=>"users"}
                      POST   /users(.:format)                                        {:action=>"create", :controller=>"users"}
             new_user GET    /users/new(.:format)                                    {:action=>"new", :controller=>"users"}
            edit_user GET    /users/:id/edit(.:format)                               {:action=>"edit", :controller=>"users"}
                 user GET    /users/:id(.:format)                                    {:action=>"show", :controller=>"users"}
                      PUT    /users/:id(.:format)                                    {:action=>"update", :controller=>"users"}
                      DELETE /users/:id(.:format)                                    {:action=>"destroy", :controller=>"users"}
             sessions GET    /sessions(.:format)                                     {:action=>"index", :controller=>"sessions"}
                      POST   /sessions(.:format)                                     {:action=>"create", :controller=>"sessions"}
          new_session GET    /sessions/new(.:format)                                 {:action=>"new", :controller=>"sessions"}
         edit_session GET    /sessions/:id/edit(.:format)                            {:action=>"edit", :controller=>"sessions"}
              session GET    /sessions/:id(.:format)                                 {:action=>"show", :controller=>"sessions"}
                      PUT    /sessions/:id(.:format)                                 {:action=>"update", :controller=>"sessions"}
                      DELETE /sessions/:id(.:format)                                 {:action=>"destroy", :controller=>"sessions"}
            passwords GET    /passwords(.:format)                                    {:action=>"index", :controller=>"passwords"}
                      POST   /passwords(.:format)                                    {:action=>"create", :controller=>"passwords"}
         new_password GET    /passwords/new(.:format)                                {:action=>"new", :controller=>"passwords"}
        edit_password GET    /passwords/:id/edit(.:format)                           {:action=>"edit", :controller=>"passwords"}
             password GET    /passwords/:id(.:format)                                {:action=>"show", :controller=>"passwords"}
                      PUT    /passwords/:id(.:format)                                {:action=>"update", :controller=>"passwords"}
                      DELETE /passwords/:id(.:format)                                {:action=>"destroy", :controller=>"passwords"}
             profiles GET    /profiles(.:format)                                     {:action=>"index", :controller=>"profiles"}
                      POST   /profiles(.:format)                                     {:action=>"create", :controller=>"profiles"}
          new_profile GET    /profiles/new(.:format)                                 {:action=>"new", :controller=>"profiles"}
         edit_profile GET    /profiles/:id/edit(.:format)                            {:action=>"edit", :controller=>"profiles"}
              profile GET    /profiles/:id(.:format)                                 {:action=>"show", :controller=>"profiles"}
                      PUT    /profiles/:id(.:format)                                 {:action=>"update", :controller=>"profiles"}
                      DELETE /profiles/:id(.:format)                                 {:action=>"destroy", :controller=>"profiles"}
               emails GET    /emails(.:format)                                       {:action=>"index", :controller=>"emails"}
                      POST   /emails(.:format)                                       {:action=>"create", :controller=>"emails"}
            new_email GET    /emails/new(.:format)                                   {:action=>"new", :controller=>"emails"}
           edit_email GET    /emails/:id/edit(.:format)                              {:action=>"edit", :controller=>"emails"}
                email GET    /emails/:id(.:format)                                   {:action=>"show", :controller=>"emails"}
                      PUT    /emails/:id(.:format)                                   {:action=>"update", :controller=>"emails"}
                      DELETE /emails/:id(.:format)                                   {:action=>"destroy", :controller=>"emails"}
               photos GET    /settings/photo_gallery/photos(.:format)                {:action=>"index", :controller=>"photos"}
                      POST   /settings/photo_gallery/photos(.:format)                {:action=>"create", :controller=>"photos"}
            new_photo GET    /settings/photo_gallery/photos/new(.:format)            {:action=>"new", :controller=>"photos"}
           edit_photo GET    /settings/photo_gallery/photos/:id/edit(.:format)       {:action=>"edit", :controller=>"photos"}
                photo GET    /settings/photo_gallery/photos/:id(.:format)            {:action=>"show", :controller=>"photos"}
                      PUT    /settings/photo_gallery/photos/:id(.:format)            {:action=>"update", :controller=>"photos"}
                      DELETE /settings/photo_gallery/photos/:id(.:format)            {:action=>"destroy", :controller=>"photos"}
         photo_albums GET    /settings/photo_gallery/photo_albums(.:format)          {:action=>"index", :controller=>"photo_albums"}
                      POST   /settings/photo_gallery/photo_albums(.:format)          {:action=>"create", :controller=>"photo_albums"}
      new_photo_album GET    /settings/photo_gallery/photo_albums/new(.:format)      {:action=>"new", :controller=>"photo_albums"}
     edit_photo_album GET    /settings/photo_gallery/photo_albums/:id/edit(.:format) {:action=>"edit", :controller=>"photo_albums"}
          photo_album GET    /settings/photo_gallery/photo_albums/:id(.:format)      {:action=>"show", :controller=>"photo_albums"}
                      PUT    /settings/photo_gallery/photo_albums/:id(.:format)      {:action=>"update", :controller=>"photo_albums"}
                      DELETE /settings/photo_gallery/photo_albums/:id(.:format)      {:action=>"destroy", :controller=>"photo_albums"}
                      GET    /photos(.:format)                                       {:action=>"index", :controller=>"photos"}
                      POST   /photos(.:format)                                       {:action=>"create", :controller=>"photos"}
                      GET    /photos/new(.:format)                                   {:action=>"new", :controller=>"photos"}
                      GET    /photos/:id/edit(.:format)                              {:action=>"edit", :controller=>"photos"}
                      GET    /photos/:id(.:format)                                   {:action=>"show", :controller=>"photos"}
                      PUT    /photos/:id(.:format)                                   {:action=>"update", :controller=>"photos"}
                      DELETE /photos/:id(.:format)                                   {:action=>"destroy", :controller=>"photos"}
                 root        /                                                       {:controller=>"users", :action=>"new"}
              success        /success(.:format)                                      {:action=>"success", :controller=>"users"}
                login        /login(.:format)                                        {:action=>"new", :controller=>"sessions"}
               logout        /logout(.:format)                                       {:action=>"destroy", :controller=>"sessions"}
       reset_password        /reset_password(.:format)                               {:action=>"new", :controller=>"passwords"}
   setup_new_password        /setup_new_password(.:format)                           {:action=>"edit", :controller=>"passwords"}
             settings        /settings(.:format)                                     {:action=>"settings", :controller=>"users"}
     settings_account        /settings/account(.:format)                             {:controller=>"users", :action=>"account"}
settings_edit_profile        /settings/edit_profile(.:format)                        {:controller=>"profiles", :action=>"edit_profile"}
                             /:username(.:format)                                    {:controller=>"users", :action=>"show"}
      change_password        /change_password(.:format)                              {:action=>"change_password", :controller=>"users"}
错误:

Routing Error

    No route matches [GET] "/settings/photo_gallery"

您可以使用:path选项。在您的情况下,它将是:

resources :photo_albums, :path => "/settings/photo_gallery"
:path
将修改资源的路径,而
scope
会在前面添加前缀,正如您在rake routes输出中看到的那样


请参见

之前尝试过此操作,但没有成功,但我只是重置了服务器,然后再次尝试,结果成功了。不知道为什么会这样。Thanksroutes更改需要重新启动服务器才能生效。不确定是不是这样?