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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:43:30+00:00 2026-05-11T01:43:30+00:00

I asked a question earlier which elicited some great responses. Here’s the earlier question

  • 0

I asked a question earlier which elicited some great responses.

Here’s the earlier question

On the back of some advice given there, I’ve tried moving the following controller logic

 if params[:concept][:consulted_legal] == 0 && params[:concept][:consulted_marketing] == 1   @concept.attributes = {:status => 'Awaiting Compliance Approval'} elsif params[:concept][:consulted_marketing] == 0 && params[:concept][:consulted_legal] == 1    @concept.attributes = {:status => 'Awaiting Marketing Approval'} elsif params[:concept][:consulted_marketing] == 0 && params[:concept][:consulted_legal] == 0   @concept.attributes = {:status => 'Awaiting Marketing & Legal Approval'} else   @concept.attributes = {:status => 'Pending Approval'} end 

into the model, as so:

def set_status if status.blank?   if (consulted_legal == true) && (consulted_marketing == true)       status = 'Pending Approval'   elsif (consulted_legal == true) && (consulted_marketing == false)     status = 'Awaiting Marketing Approval'   elsif (consulted_legal == false) && (consulted_marketing == true)     status = 'Awaiting Legal Approval'   elsif (consulted_legal == false) && (consulted_marketing == false)     status = 'Awaiting Marketing & Legal Approval'   end end true # Needs to return true for the update to go through       end 

I am calling that from a before_save callback.

As a default, both the consulted_legal and consulted_marketing attributes are set to false and not null, which is why I am testing for == false or true here, instead of asking

if consulted_legal? 

for instance.

However, this logic doesn’t seem to be working. If I inspect the object, status is not being set to anything, ever. Can anyone spot why this might be happening? Have I got how attributes are accessed wrong in models, for instance?

TIA

  • 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. 2026-05-11T01:43:30+00:00Added an answer on May 11, 2026 at 1:43 am

    Instead of status = try self.status =. I’ve found that I needed to use self. to change a model’s attribute within the model.

    It’s also much better to have errors.empty? at the end instead of true, so if you ever use errors.add_to_base in the future, your set_status method is ready to abort a save.

    Edit:
    You may also want to check out acts_as_state_machine. It looks like a plugin for exactly what you’re doing.

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

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer In order to have a view state enabled you must… May 11, 2026 at 12:41 pm
  • added an answer Yes, the BASS library can do this. http://www.un4seen.com C# wrappers… May 11, 2026 at 12:41 pm
  • added an answer The release notes for TestDriven.NET 2.19 mention that this problem… May 11, 2026 at 12:41 pm

Related Questions

I asked a question earlier which elicited some great responses. Here's the earlier question
I asked a question earlier about which language to use for an AI prototype.
I asked a question earlier , and got an excellent response, but, being a
Ok, I asked a question earlier about Flex and ADO.NET Data Services but didn't
Earlier I asked a question about why I see so many examples use the
This stems out of How can one number paragraphs in LaTeX? , which I
NOTE I have asked the related question: How to combine DataTrigger and EventTrigger? I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.