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 8888695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:05:57+00:00 2026-06-14T22:05:57+00:00

In my simple Rails 3 application I have a has_one, has_many relationship between two

  • 0

In my simple Rails 3 application I have a has_one, has_many relationship between two models. I am passing the id of the ‘owner’ to the child upon creation:

Animal Model

has_many :claims, :foreign_key => 'animal_id'
has_many :conditions, :foreign_key => 'animal_id'

Claim Model

has_one :animal, :foreign_key => 'PVID'
has_many :payments, :dependent => :destroy

Payment Model

belongs_to :claim

I am passing the animal_id and claim_id to the claim and payment models respectively using hidden forms.

What I would like to do is redirect the user to the parent model upon creation. So, for example:

If the user was creating a new claim, the claim form would automatically have the animal_id inserted. What is the correct way to redirect back to the animals record?

format.html { redirect_to claim_animal_path, notice: 'Claim was successfully created.' }

Any pointers would be appreciated!

  • 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-14T22:05:58+00:00Added an answer on June 14, 2026 at 10:05 pm

    Depending on your routes file, the animal_path helper will accept an id for an animal. Something like

    format.html { redirect_to animal_path @claim.animal.id, notice: 'Claim was successfully created.' }
    

    would probably work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple rails application were book belongs_to user and user has_many book.
I am new to rails and have developed a simple rails application on my
I have a simple rails 2.3.4 application I am trying to get running with
I have created a simple blog application with Ruby on Rails. The applications consists
I have a Rails 3.2.2 application which is a simple company intranet, however although
I have built a very simple blog application using Ruby on Rails. New to
I'm learning Rails by writing simple TODO tasks aplication. Two models are: class List
I have a simple application with a customer and appointment models, system admin can
I have a really simple Rails application that allows users to register their attendance
I have a simple rails 3 application that lists restaurants as a training exercise.

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.