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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:26:51+00:00 2026-06-06T11:26:51+00:00

I have setup some simple associations in my rails app: resources :properties do resources

  • 0

I have setup some simple associations in my rails app:

resources :properties do
 resources :units
end

After updating a unit:

‘localhost:3000/properties/2/units/3/edit’

I want to be redirected back to the appropriate location.

after I click “Update” I am redirected back to:

‘localhost:3000/units/3’, but should go to ‘localhost:3000/properties/2/units/3/’

In my units controller, I have:

if @unit.update_attributes(params[:unit])
    format.html { redirect_to(property_units_path(@property, @unit), :notice => 'Unit was successfully updated.') }
    format.xml  { head :ok }
  else
    format.html { render :action => "edit" }
    format.xml  { render :xml => @unit.errors, :status => :unprocessable_entity }
  end

Is this the appropriate use in my redirect_to function? I am still trying to become familiar with how the routes work but I feel like this should work?

Thanks!

  • 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-06T11:26:52+00:00Added an answer on June 6, 2026 at 11:26 am

    You are almost there. You should redirect to:

    format.html { redirect_to(property_unit_path(@property, @unit), :notice => 'Unit was successfully updated.') }
    

    Note that your must use the singular version of the routing helper method for this to work. For more details check the rails guide on routing.

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

Sidebar

Related Questions

I have setup simple scenario to learn about databinding in XAML. After some thinking
My current setup : I have an entity object with some properties, among them
I have a rails app running on Heroku. I am using paperclip for some
I have a small c# wpf app for doing some simple calculations running off
I have some setup code in my functions.php file that sets permalinks and adds
I have setup ability for a user to specify some settings using the in-built
I have setup mappings for a number of classes, however in some scenarios I
Some setup background first: I have a cronjob which runs a PHP file called
I have a setup function that runs onload to add some behaviours to elements.
Using Apache Wicket 1.4: I have a panel that calls some setup Javascript in

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.