Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:50:48+00:00 2026-05-28T16:50:48+00:00

I am trying to create a REST API for my app. The map.connect_resource :book

  • 0

I am trying to create a REST API for my app.

The map.connect_resource :book causes the following error, when executing rake test:functionals:

Error: undefined local variable or method `map' for # 
<ActionDispatch::Routing::Mapper:0x8a11e74>.

In my app, I’m trying to implement RoR with MySQL with the following table data.

Table Name: Object  
Fields: object_id, Object_name, Object_description etc...

I would like to create a REST API object for querying the above database and retrieving the data. What’s the best way to proceed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:50:48+00:00Added an answer on May 28, 2026 at 4:50 pm

    That is a reallyyyyyyy old tutorial (from 6 years ago!!!). I would recommend reading this guide instead: http://guides.rubyonrails.org/routing.html

    Assuming you are running Rails 3, you should just put this in your routes.rb file:

    resources :books
    

    That will expose routes for your BooksController so you can access:

    HTTP Verb   Path              action      used for
    -----------------------------------------------------------------------
    GET         /books            index       display a list of all books
    GET         /books/new        new         return an HTML form for creating a new book
    POST        /books            create      create a new book
    GET         /books/:id        show        display a specific book
    GET         /books/:id/edit   edit        return an HTML form for editing a book
    PUT         /books/:id        update      update a specific book
    DELETE      /books/:id        destroy     delete a specific book
    

    So in your BooksController you would then have:

    class BooksController < ApplicationController
      # GET /books
      # GET /books.xml
      def index
        @books = Book.all
    
        respond_to do |format|
          format.html # index.html.erb
          format.xml  { render :xml => @books }
        end
      end
    
      # GET /books/1
      # GET /books/1.xml
      def show
        @book = Book.find(params[:id])
    
        respond_to do |format|
          format.html # show.html.erb
          format.xml  { render :xml => @book }
        end
      end
    
      # GET /books/new
      # GET /books/new.xml
      def new
        @book = Book.new
    
        respond_to do |format|
          format.html # new.html.erb
          format.xml  { render :xml => @book }
        end
      end
    
      # GET /books/1/edit
      def edit
        @book = Book.find(params[:id])
      end
    
      # POST /books
      # POST /books.xml
      def create
        @book = Book.new(params[:book])
    
        respond_to do |format|
          if @book.save
            format.html { redirect_to(@book, :notice => 'Book was successfully created.') }
            format.xml  { render :xml => @book, :status => :created, :location => @book }
          else
            format.html { render :action => "new" }
            format.xml  { render :xml => @book.errors, :status => :unprocessable_entity }
          end
        end
      end
    
      # PUT /books/1
      # PUT /books/1.xml
      def update
        @book = Book.find(params[:id])
    
        respond_to do |format|
          if @book.update_attributes(params[:book])
            format.html { redirect_to(@book, :notice => 'Book was successfully updated.') }
            format.xml  { head :ok }
          else
            format.html { render :action => "edit" }
            format.xml  { render :xml => @book.errors, :status => :unprocessable_entity }
          end
        end
      end
    
      # DELETE /books/1
      # DELETE /books/1.xml
      def destroy
        @book = Book.find(params[:id])
        @book.destroy
    
        respond_to do |format|
          format.html { redirect_to(books_url) }
          format.xml  { head :ok }
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a very simple REST server. I just have a test
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
I'm trying to build a REST-ful API for my app. Currently I have something
Given: I'm trying to create a REST API using ASP.NET MVC . I'm using
I'm trying to create a REST web service that exposes the following Django model:
Situation I'm trying to create a REST API, where users can request responses in
I'm trying to create a WCF client that accesses a REST API. The API
I'm trying to create a JSON REST api using Happstack. It should allow POSTS
I'm trying to create a REST service in zend framework. I'm using zend server.
I've got a simple REST based service for which I am trying to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.