SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Big problem I cant figure this out.

    Im going to do a walk through of my problem. It involves the scaffolding.

    I was trying to scaffold the basic part of a forum im going to show you exactly what i did.

    I started by opening cmd and typing: rails forums

    It created the first part.


    I then, created the database's
    Had no problem doing this.

    The database.yml file is perfect as well this is the database tho.

    PHP Code:
    CREATE TABLE `forums` (
      `
    idint(11NOT NULL auto_increment,
      `
    titlevarchar(255collate latin1_general_ci NOT NULL default '',
      `
    descriptiontext collate latin1_general_ci NOT NULL,
      
    PRIMARY KEY  (`id`)
    )  ; 


    After "Everything" was done. this is where it runs into problems

    I ran scaffold i typed:
    ruby script/generate scaffold forums
    it created the controllers and everything.
    I then went to routes.rb and edited it

    PHP Code:
    ActionController::Routing::Routes.draw do |map|
      
    # The priority is based upon order of creation: first created -> highest priority.
      
      # Sample of regular route:
      # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
      # Keep in mind you can assign values other than :controller and :action

      # Sample of named route:
      # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
      # This route can be invoked with purchase_url(:id => product.id)

      # You can have the root of your site routed by hooking up '' 
      # -- just remember to delete public/index.html.
       
    map.connect '', :controller => "forums"

      
    # Allow downloading Web Service WSDL as a file with an extension
      # instead of a file named 'wsdl'
      
    map.connect ':controller/service.wsdl', :action => 'wsdl'

      
    # Install the default route as the lowest priority.
      
    map.connect ':controller/:action/:id'
    end 
    I deleted the index in the public html.

    I then ran: ruby script/server

    It then gave this error
    http://minnisite.com/sss.JPG

    and i gave this to the IRC channel for Rails. They couldnt even help me I posted my forums_controller.rb
    here is it:

    PHP Code:
    class ForumsController ApplicationController
      def index
        
    list
        
    render :action => 'list'
      
    end

      
    # GETs should be safe (see [url]http://www.w3.org/2001/tag/doc/whenToUseGet.html[/url])
      
    verify :method => :post, :only => [ :destroy, :create, :update ],
             :
    redirect_to => { :action => :list }

      
    def list
        @
    forums_pages, @forums paginate :forums, :per_page => 10
      end

      def show
        
    @forums Forums.find(params[:id])
      
    end

      def 
    new
        @
    forums Forums.new
      
    end

      def create
        
    @forums Forums.new(params[:forums])
        if @
    forums.save
          flash
    [:notice] = 'Forums was successfully created.'
          
    redirect_to :action => 'list'
        
    else
          
    render :action => 'new'
        
    end
      end

      def edit
        
    @forums Forums.find(params[:id])
      
    end

      def update
        
    @forums Forums.find(params[:id])
        if @
    forums.update_attributes(params[:forums])
          
    flash[:notice] = 'Forums was successfully updated.'
          
    redirect_to :action => 'show', :id => @forums
        
    else
          
    render :action => 'edit'
        
    end
      end

      def destroy
        Forums
    .find(params[:id]).destroy
        redirect_to 
    :action => 'list'
      
    end
    end 
    Then they asked me to post the forums.rb so here it is.
    forums.rb

    PHP Code:
    class Forums ActiveRecord::Base
    end 



    What is Wrong guys? I get that error everytime. i do something.

  2. #2
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is looking for Forum , not Forums.
    The class name should be singular while the database name should be pluralized.

    Try it with forum.rb and forum_controller.rb
    with
    class Forum < ActiveRecord::Base
    and
    class ForumController < ApplicationController

    then change the references of Forums to Forum

    that is my best guess.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now im having difficulties inside of the localhost/forum/new
    localhost/forum works now but cant get the other part to work i keep messing with it and no luck.


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
  •