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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:02:59+00:00 2026-05-17T20:02:59+00:00

I try: @item.associations.update_attributes(:tag_id=>params[:tag]) and @item.associations.tag_id=params[:tag] Both give me undefined method errors for update_attributes and

  • 0

I try:

@item.associations.update_attributes(:tag_id=>params[:tag])

and

@item.associations.tag_id=params[:tag]

Both give me undefined method errors for update_attributes and tag_id=, respectively. Here’s my setup:

class Item < ActiveRecord::Base
  has_many :associations,:foreign_key=>"item_id",:dependent=>:destroy
  has_many :reverse_associations,:foreign_key=>"tag_id",:class_name=>"Association"
  has_many :tags,:through=>:associations
end

class Tag < ActiveRecord::Base
  has_many :associations,:foreign_key=>"tag_id",:dependent=>:destroy
  has_many :reverse_associations,:foreign_key=>"item_id",:class_name=>"Association"
  has_many :items,:through=>:associations
  attr_accessible :name
end

class Association < ActiveRecord::Base
  belongs_to :item
  belongs_to :tag
end

What am I doing wrong?

  • 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-05-17T20:03:00+00:00Added an answer on May 17, 2026 at 8:03 pm

    You’re trying to update tag_id on the entire @item.associations collection instead of updating a single Assocation instance.

    The proper way to solve this depends on what you’re trying to accomplish. To update the tag_id for all associations in @item.association, try:

    @item.associations.each do |association|
      association.update_attributes(:tag_id => params[:tag])
    end
    

    If you want to update the tag id for a specific Association, then you somehow need to get that association first:

    # Just picking the first association for the item as an example.
    # You should make sure to retrieve the association that you actually
    # want to update.
    retagged_association = @item.associations.first
    
    # Now, retag the association
    retagged_association.update_attributes(:tag_id => params[:tag])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my code: 1.Java Code: public static void getImg(Long itemId) { try { Item
When I try to add an item into an assication /** * In Note
I try to write the following in latex: \begin{itemize} \item \textbf{insert(element|text)} inserts the element
Getting this error when try to add an item to my repositories/context: Collection has
I'm try to change text color and align item in spinner to center of
Im getting a -1 value when i try to get the selected item position
I am getting an error when I try to insert an item into a
$(item).droppable({ drop: function(event, ui) { console.log(triggered); } }); I try to call drop by
I'm often having code written as follows try: self.title = item.title().content.string except AttributeError, e:
I try to use amazon API using PHP. If I use print_r($parsed_xml->Items->Item->ItemAttributes) it show

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.