ログインフォームを実装しようとしていますが、ルーティングが間違っているようです。認証が失敗すると、アプリは subdomain.domain.com/login にリダイレクトしますが、ログイン ページのみを再度レンダリングする必要があります ("/login" のない subdomain.domain.com のみ)。
ビュー/ログイン/index.html
<%= form_tag(check_login_path, :method => "post") do %>
... form fields
<% end %>
ルート.rb
constraints(Subdomain) do
match '/' => 'login#index', :as => :login
match '/login' => 'login#check', :as => :check_login
match '/dashboard' => 'dashboard#index', :as => :dashboard
end
login_controller.rb
class LoginController < ApplicationController
def index
# some index logic
end
def check
# authenticate with mite.yo.lk account login
Mite.account = params[:domain]
Mite.authenticate(params[:email], params[:password])
if Mite.validate
redirect_to dashboard_path
else
flash[:error] = "not valid"
render :template => 'login/index'
end
end
end