我应该在routes.rb中添加/删除哪些内容以确保下面的链接有效?
我的观点(登录链接)
<%- if controller_name != 'sessions' %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<% end -%>
我的路线:
devise_for :users
devise_scope :user do
root to: 'static_pages#home'
match '/sessions/user', to: 'devise/sessions#create', via: :post
end`
视图产生的网址是&#39; /sessions/new.user'
我在渲染视图中收到以下错误。
缺少模板
Missing template sessions/new, application/new with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :rtf, :pdf], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/Users/toad/Code/version1h/edwave/app/views" * "/Users/toad/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/devise-3.2.4/app/views"
答案 0 :(得分:1)
设计路由嵌套在资源中。所以路径应该是
<%= link_to "Sign in", new_user_session_path %>