English 中文(简体)
收集路线的匹配
原标题:Match of routes in the collection

我以这种方式界定了我控制员的每一项行动(见routes.rb):

  resources :home do
    collection do
      get "home/index"
      get "home/about_me"
      get "home/contact"
    end
  end

如果我对行动使用匹配about_me,我必须使用。

      resources :home do
        collection do
          get "home/index"
          get "home/about_me"
          get "home/contact"
        end
      end

      match  about-me  =>  home#about_me 

无论如何,如何添加<代码>match 规则直接用于收集? 我指的是:

  resources :home do
    collection do
      get "home/index"
      get "home/about_me", match => "about-me"
      get "home/contact"
    end
  end

还有一个问题——在我使用<条码>时。 第2组代码,因此,当我确定URL地址about-me时,地址是罚款,但当我有<代码>home/about_me时,我就发现错误。

www.un.org/Depts/DGACM/index_spanish.htm 不详的行动: 内部主计长无法找到行动。

造成这一错误的原因是什么?

最佳回答

我认为,这里的问题是,你的航道有<条码>。 在<代码>资源:home内封顶。 为此:

 resources :home do
   collection do
     get :index
     get :about_me
     get :contact
   end
 end

Also, when you have trouble setting your routes, type rake routes in your console. This will generate the routes of your app and the corresponding paths and controllers.

页: 1

resources :home do
  collection do
    get  about_me  =>  about-me 
  end
end
问题回答

暂无回答




相关问题
Rails: Proxy Pass?

I ve got a web-app that I want to migrate to Rails, which is currently just plain HTML with an Apache proxy to another server, running a custom database/webserver that serves the site s dynamic ...

MVC routing is not handling one of my directories

I m using ASP.NET MVC with IIS 7.0. I ve got 404 errors hooked up fine through my Application_Error override. In addition to "Controllers", "Models", "Helpers" etc. I have a directory called Files ...

Ruby on Rails conditional routing

I have a site listing many jobs, but I also want each account to be able to access its jobs in one place. Thus, I am using these routes: map.resources :jobs map.resource :account, :has_many => :...

Clean URL s using OpenCart s router class

How do you write clean URL s in OpenCart using their built in Router class? Here is my .htaccess file: RewriteEngine On RewriteRule ^(system) - [F,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...

subdomain routing to multiple controller issue

I have a site: www.mydomain.com where we have administrative controls hidden away from normal customer view. I would like to only access the administrative features under a subdomain such as admin....

Can controller names in RESTful routes be optional?

With a standard map.resource routing mechanics and several nested resources the resultant routes are unnecessarily long. Consider the following route: site.org/users/pavelshved/blogs/blogging-horror/...

Help with rails routes

Im having a little trouble setting up routes. I have a users controller/model/views set up restfully so users is set up to be a resource in my routes. I want to change that to be usuarios ...

热门标签