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

  • Home
  • SEARCH
  • 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 8310457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:28:01+00:00 2026-06-08T19:28:01+00:00

I am trying to write a simple api using ruby and rails and have

  • 0

I am trying to write a simple api using ruby and rails and have almost got it working, I am just having one issue. When I try and create a nested resource, I receive an “undefined method” error.

I have two models, one is a user model and one is a record model. They are setup in the routes.rb as such:

resources :users, :except => [:new,:edit] do
  resources :records, :except => [:new,:edit]
end

My records controller contains the following:

def show
  respond_with @user.records.find(params[:id])
end

def create
  respond_with @user.records.create(params[:record])
end

When I call show with a parameter, it works and returns the model. When I post a create I get the following error:

NoMethodError: undefined method `record_url' for #<RecordsController:0x007fea3682a5c8>

I am not sure why this is occuring but if anyone has any ideas I would be grateful. Also, if any more code is required to help, tell me so that I can add it.

Forgot to add my rake routes:

user_records GET    /users/:user_id/records(.:format)     records#index
             POST   /users/:user_id/records(.:format)     records#create
 user_record GET    /users/:user_id/records/:id(.:format) records#show
             PUT    /users/:user_id/records/:id(.:format) records#update
             DELETE /users/:user_id/records/:id(.:format) records#destroy
       users GET    /users(.:format)                      users#index
             POST   /users(.:format)                      users#create
        user GET    /users/:id(.:format)                  users#show
             PUT    /users/:id(.:format)                  users#update
             DELETE /users/:id(.:format)                  users#destroy
  • 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-06-08T19:28:03+00:00Added an answer on June 8, 2026 at 7:28 pm
    @record =  @user.records.create(params[:record])
    respond_with(@user, @record)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple maze game, without using any deprecated OpenGL API
I have been trying to write a simple mention grabber to get started with
I'm trying to write a simple command line audio player using the Python Gstreamer
I'm trying to write a voip app for Android, using the Android SIP API
I'm trying to write a simple program using WinSnmp in C++. There is very
Trying to write a simple call to google's JSON stock ticker API. I would
I'm trying to write a simple paint applet with Java, but I'm having trouble
I'm trying to write a 3D game in ActionScript 3.0 using the Stage3D API.
I'm trying to open a simple window through the Win32 API, using the VC++
I'm trying to write a simple client-side text editor using HTML5 and Javascript. Is

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.