1-私のコントローラーはこれですが、この名前がlogin.html.erbである場合、これはビューを呼び出しません。これが何が起こるかわからないので、ログインの形式を表示することです。
class FinancesController < ApplicationController
# GET /finances
# GET /finances.json
def login
@user = User.find_by_name(params[:user])
if @user
session[:user_id] = @user.id
redirect_to :action => 'index'
else
redirect_to login_url
end
end
def index
@finances = Finance.all(:order => "created_at")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @finances }
end
end
2-誰かが私に話しかけて、ユーザーとパスワードがいくつかのフォームにあるサンプルログインを検証するために認証方法を使用することができます。この方法の使用方法を教えてください。find_by_name_and_passwordは機能しません。
多くの回答に感謝します。
Routes.rb
Controle::Application.routes.draw do
match 'login' => 'finances#login'
resources :finances
end