我非常新的轨道,我最近有一个问题.. 我做了一个登录页面看起来就像是:Ruby on Rails的 - 无路由匹配[POST]“/登录/指数”
<!DOCTYPE html>
<div id="content">
<form action="#" method="POST" id="login-form">
<fieldset>
<p>
<label for="login-username">username</label>
<input type="text" id="login-username" class="round full-width-input" autofocus />
</p>
<p>
<label for="login-password">password</label>
<input type="password" id="login-password" class="round full-width-input" />
</p>
<!--<a href="dashboard.html" class="button round blue image-right ic-right-arrow">LOG IN</a>
<%= link_to "Add to your favorites list", '/login/index', { :class=>"button round blue image-right ic-right-arrow" } %>-->
<%= submit_tag "Login" %>
</fieldset>
</form>
</div> <!-- end content -->
这种观点下的应用程序/意见/登录/ index.html.erb 匹配控制器下的应用程序/控制器/ login_controller.erb,看起来像:
class LoginController < ApplicationController
def index
end
def login
end
end
和我的路由看起来像这样:
BonhamNew::Application.routes.draw do
get "login/index"
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'login#index'
end
当我点击了透过,我得到: 没有路由匹配[POST]“/登录/指数”
我知道它很基本的,但也许some1可以在这里给我一个忙吗?
谢谢!
嗨,似乎工作,但现在当我点击按钮,我得到:在LoginController#索引ActionController :: InvalidAuthenticityToken什么可以导致该问题? – gal
@gal,这是与你不使用'form_tag'助手,请参阅我的答案。 – amnn