I am new to Rails and am just implementing some basic applications. Just starting on my second app and have run into what is a basic problem, but Google is yielding me nothing.
Getting this error:
No route matches {:controller=>"user", :action=>"admin_login"}
Here is my routes.rb
Blah::Application.routes.draw do
resources :items, :cart, :user
end
Here is my applications.html.erb (the idea is this is a header of course, and I'm trying to create a link to 'login'. Right now it's just supposed to set the 'login' session variable to '1'.
class UserController < ApplicationController
def index
end
def admin_login
session[:login] = 1
session[:cart] = nil
flash[:notice] = "Admin user successfully logged in, cart reset."
redirect_to :controller => :items
end
end
What am i missing in my routes.rb? Or otherwise...am sure it's something daft.
解决方案
You need to add admin_login method to routes, like:-