views:

150

answers:

2

I'm following this article.(http://asciicasts.com/episodes/160-authlogic), I'm not using nifty generator tho.

I've done with User model and 'localhost:3000/users/new' page works find.

But 'localhost:3000/user_sessions/new' page does not work as I expected. I've just copied the source from the site.

routes.rb

map.login 'login', :controller => 'user_sessions', :action => 'new'
map.logout 'logout', :controller => 'user_sessions', :action => 'destroy'
map.resources :user_sessions
map.resources :users

user_sessions_controller.rb

class UserSessionsController < ApplicationController
  def new
    @user_session = UserSession.new
  end

  def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = "Successfully logged in."
      redirect_to root_url
    else
      render :action => 'new'
    end
  end

  def destroy
    @user_session = UserSession.find
    @user_session.destroy
    flash[:notice] = "Successfully logged out."
    redirect_to root_url
  end
end

/views/user_sessions/new.html.erb

<% form_for @user_session do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.label :username %><br />
    <%= f.text_field :username %>
  </p>
  <p>
    <%= f.label :password %><br />
    <%= f.password_field :password %>
  </p>
  <p><%= f.submit "Submit" %></p>
<% end %>

As you see, the code is just same as the site. But, when I try to open 'localhost:3000/login', the page is just empty. And also, if I see the source from the browser, empty again.

Why, there's no login form? What happen? Please give me any clue...

ps. After added new action 'index' into user_sessions controller(also plus index.html.erb), if I open 'localhost:3000/user_sessions/index' shows me below message.

Unknown action

No action responded to show. Actions: create, destroy, index, and new

And, this is WEBrick output

Processing UserSessionsController#show (for 127.0.0.1 at 2010-01-22 12:47:10) [GET]

Parameters: {"id"=>"index"}

ActionController::UnknownAction (No action responded to show. Actions: create, destroy, index, and new):

+1  A: 

/views/new.html.erb should be located at views/user_sessions/new.html.erb

Ben
Sorry, it is where you noted. miss typing. I've modified the path in my question.
Hongseok Yoon
+1  A: 

I've found the reason.

There was nothing in Views/layouts/application.html.erb, the file is exist, tho.

SHIT!!!

Hongseok Yoon