SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast stef686's Avatar
    Join Date
    Aug 2005
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with SitePoint RoR book

    I seem to be having an odd problem with the login page html on page 240. I've downloaded the code archive and checked the latest errata but still doesn't work, I don't know if there is an error in my controller that might be causing it?

    The odd thing is the form isn't showing at all. I am getting the application html (header, footer, layout etc) but no login form is being displayed. Here's my code, if anyone has any suggestions I'd be very greatful!

    login.rhtml
    Code:
    <% form_tag do %>
      <p>Please log in.</p>
      <p>
        <label>Username:</label>
        <%= text_field_tag 'login' %>
      </p>
      <p>
        <label>Password:</label>
        <%= password_field_tag 'password' %>
      </p>
      <p><%= submit_tag 'login' %></p>
    <% end %>
    account_controller.rb
    Code:
    class AccountController < ApplicationController
    
      def login
      	if request.post?
      		@current_user = User.find_by_login_and_password(params[:login], params[:password])
      		unless @current_user.nil?
      			session[:user_id] = @current_user.id
      			redirect_to :controller => 'story'
      		end
      	end
      end
    
      def logout
      
      end
      
    end

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where is login.rhtml located. It should be in a folder within views that corresponds to the controller. So the file path should be app/views/account/login.rhtml judging by the controller name.

    Also are you just not seeing a log on screen, or are you being redirected to a story view without being prompted to log on?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •