【发布时间】:2014-07-05 12:02:29
【问题描述】:
我不知道为什么,但最近我尝试更改路线以将新项目添加到
/project/new 而不是渲染 new.html.haml 它渲染 show.html.haml 并且 new 是参数。
在我的 routes.rb 中
Mika::Application.routes.draw do
root "pages#home"
get '/contact' => "pages#contact"
get '/about' => 'pages#about'
get '/privacy' => 'pages#privacy'
get '/tos' => 'pages#terms_of_service'
post '/contact' => 'messages#contact'
resources :projects, :only => [:index, :show]
resources :projects, :only => [:update, :edit, :create, :post, :new], :constraints => { :subdomain => 'admin' }
end
我不完全确定从哪里解决这个问题,甚至什么时候开始
在终端我得到了这个
Started GET "/projects/new" for 127.0.0.1 at 2014-05-16 15:23:20 -0700
Processing by ProjectsController#show as HTML
Parameters: {"id"=>"new"}
Rendered projects/show.html.haml within layouts/application (0.1ms)
Rendered layouts/_shim.html.haml (0.8ms)
Rendered layouts/_header.html.haml (0.5ms)
Rendered layouts/_footer.html.haml (0.2ms)
Rendered layouts/_javascript.html.haml (0.0ms)
Rendered layouts/_analytics.html.haml (0.0ms)
Completed 200 OK in 9ms (Views: 8.0ms | ActiveRecord: 0.0ms)
*EDIT 将路由文件更改为此工作
resources :projects, :only => [:update, :edit, :create, :post, :new], :constraints => { :subdomain => 'admin' }
resources :projects, :only => [:index, :show]
但它仍在为不存在的参数渲染创建,结果为空白页
【问题讨论】:
-
:new 在下面,如果你看到只有管理员可用。
标签: ruby-on-rails routes url-parameters