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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:22:43+00:00 2026-06-04T17:22:43+00:00

hello i was wondering if it was possible to retrieve the :id (the primary

  • 0

hello i was wondering if it was possible to retrieve the :id (the primary key that auto-increments in the db) after it gets saved? i have in my favorite_relationships controller

def create
    @lesson = Lesson.find(params[:favorite_relationship][:lesson_id])
    current_user.favorite!(@lesson)
    #params[:id] = ...
    respond_to do |format|
      format.html { redirect_to @lesson }
      format.js
    end
end

when current_user.favorite! gets called, it goes to my user model

  def favorite!(lesson)
    favorite_relationships.create!(lesson_id: lesson.id)
  end

however, is there a way to retrieve the :id the favorite_relationship is getting saved as? i wanted to set it in the commented out line

#params[:id] = 

i need to specify a params[:id] for a gem im using

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-04T17:22:44+00:00Added an answer on June 4, 2026 at 5:22 pm

    I assume you are looking for favorite_relationships.id? in this case modify you controller to strore the value in the variable as

    favorite_relationships = current_user.favorite!(@lesson)
    params[:id]= favorite_relationships.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if it's possible to have a function in a class, that
Hello I was wondering whether this is possible. I have a horizontal menu created
Hello android designers, 1-I have been wondering. Is it a good design approach to
Hello i was wondering if it is possible and if so how? to do
Hello I was wondering if it was possible to store a double into a
Hello I am wondering whether it is possible to do this type of regex:
Hello People of Stackoverflow, I was wondering if it was possible to compile a
I'm wondering if anyone knows if it's possible in XAML to have a ListBox
Hello i'm wondering if its not possible to set the right column to the
Hello I am wondering if it is possible to change the orientation of 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.