以下部分:
<%= form_for @user_session, :url => user_session_path do |f| %>
<%= f.error_messages %>
<span class="field-group">
<div>
<%= f.label :login, "Login Name:" %><br />
<%= f.text_field :login %><br />
</div>
</span>
<div class="clear"></div>
<span class="field-group">
<div>
<%= f.label :password, "Password:" %><br />
<%= f.password_field :password %> <span class="hint">Reminder: Your password is case sensitive.</span><br />
</div>
</span>
<div class="clear"></div>
<span class="field-group">
<div>
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
</div>
</span>
<div class="clear"></div>
<%= f.submit "Login" %>
<% end %>
和以下路線:
$ rake routes | grep user_session | grep show
user_session GET /user_session/:id(.:format) {:action=>"show", :controller=>"user_session"}
和以下路線配置:
# user session stuff
resources :user_session do
member do
put :forgot_password
put :terms
get :terms
end
end
match '/login', :to => 'user_sessions#new', :as => 'login'
match '/logout', :to => 'user_sessions#destroy', :as => 'logout'
問題:
當我調用使用這個部分,我得到以下錯誤頁面:
ActionController::RoutingError in User_sessions#new
Showing /app/views/edit_shared/_login.html.erb where line #2 raised:
No route matches {:action=>"show", :controller=>"user_session"}
提取的源(左右線#2):
1:
2: <%= form_for @user_session, :url => user_session_path do |f| %>
3: <%= f.error_messages %>
4: <span class="field-group">
5: <div>
所以這條路線存在,但鐵軌說它沒有。那麼是什麼給了?直到我開始升級到Rails 3.0.5爲止沒事。
ël,看我的編輯。我添加了我的'user_session'路由信息。我認爲使用'資源:user_session do ... end'足以獲得我需要的路由。我應該添加什麼? – DJTripleThreat 2011-05-09 23:46:22
我更新了答案。 – 2011-05-10 06:30:40