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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:52:15+00:00 2026-05-30T19:52:15+00:00

I am using a code where for updating fields i have to use different

  • 0

I am using a code where for updating fields i have to use different methods based on some condition. code snippet looks like

   @issue = Issue.find(some_id) # Issue is ActiveRecord class

  if 'class fields' # some condition checking
    @issue.send("status").name = data     # status is a class and name is its attribute
    @issue.save
  else
    @issue.update_attribute("subject", data) # subject is a string
  end

i am looking for a solution where i can use update_attribute to update class attributes
for e.g.

@issue.update_attribute(@issue.:status.name, data) # invalid 

may be i am doing some thing silly
but i want to know a better approach

thnx.

  • 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-30T19:52:16+00:00Added an answer on May 30, 2026 at 7:52 pm

    You need use the accepts_nested_attributes_for ( system.

    In your Issue class your need define your status association like nested_attributes

    class Issue < AR
      has_one :status
      accepts_nested_attributes_for :status
    end
    

    After you can update your status by

    @issue.update_attribute({:status_attributes => {'name' => 'data'}})
    

    PS : You can’t do it on belongs_to associations.

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

Sidebar

Related Questions

After updating to Parsec 3.1 from 2.x, code using many1, such as word =
I installed a windows service using installUtil.exe. After updating the code I used installUtil.exe
I have been using code similar to this MessageDlg('', mtWarning, [mbOK], 0); throughout my
I'm using code in the Application_BeingRequest() handler of my Global.asax to do some very
I have a code in javascript and I am using jQuery Calculation plugin (can
I am have some problem in updating my qotwVote1a table's Vote1a field through PHP.
I'm using Entity Framework Code First and whilst I have working code, I'm having
I'm using code that I found on the CodeProject.com for a low-level keyboard hook
I've recently started using code coverage tools (particularily Emma and EclEmma), and I really
I'm using code that takes a bitmap and converts it to 24 BPP so

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.