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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:22:11+00:00 2026-06-10T00:22:11+00:00

I have a User model, which :has_many :widgets Here is the ‘edit’ method: def

  • 0

I have a User model, which :has_many :widgets

Here is the ‘edit’ method:

  def edit
    @user = current_user
    @user.widgets.build   
  end

I have an edit view which contains a user form and a widget form nested within it

In my UserController#update method, I save the data…all working as designed.

After save, I want to send the user to Widget#show with the ID of the widget that was just added to User.widgets

How do I get that ID?

Here is my update method:

 def update
    @user = User.find(params[:user][:id], :include => [:widgets])
    if @user.update_attributes(params[:user])
       redirect_to widget_path(????), notice: 'Your new Widget is ready' }
    end
  end
  • 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-10T00:22:13+00:00Added an answer on June 10, 2026 at 12:22 am

    Couldn’t you scope the @user.widgets.last.id request so that you are assured of getting their last widget, something like: @user.widgets.created_by(@user).last.id

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

Sidebar

Related Questions

I have a User model which has_many Documents. Each Document's title must be unique
Say I have a model User which has_many Post children. Obviously I can access
I have an model (User) which has a has_many relationship to another model (Resource).
I have a model User which has_many :messages and Message which belong_to :user. when
Hi I have a User model which has_many :devices has_many :events, :through => :devices.
Let's say I have a User model which has_many :posts , while Post has_many
I have a User model and the user has a relationship which is has_many
Ive got the following problem. I have a model called user which has a
I have a simple User model which is associated to many Town objects using
I have a user model on which I check to make sure that the

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.