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
I assume you are looking for favorite_relationships.id? in this case modify you controller to strore the value in the variable as