SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with SImply Rails2 Chapter 8

    On page 263 it give the following code
    Code:
      def create
        @current_user = User.find_by_login_and_password(
          params[:login], params[:password])
    
        if @current_user
          session[:user_id] = @current_user.id
          redirect_to stories_path
        else
          render :action => 'new'
        end
      end
    For some reason when I go to test it out it says "Template is missing
    Missing template sessions/create.html.erb in view path /home/jonah/shovell/app/views". The page should be going my main stories page.

    Jonah

    Yes I have configured routes.rb.

  2. #2
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't actually need the create.html.erb since a valid login goes to the stories page and an invalid one goes back to the login page.

    1)
    I would add some puts statements in there to figure out which part of the if statement you are getting sent to.

    2) Run 'rake routes' to make sure you have a route for the stories_path that you reference. When you run that command you should see a full list of valid routes.

    In my output from this command I see (among many lines):

    stories GET /stories {:controller=>"stories", :action=>"index"}


    The first part (stories) is what must preceed the '_path' to be valid.

    3) When I change the routes I typically restart Mongrel just to make sure it has the latest routes.


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
  •