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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:24:20+00:00 2026-06-06T13:24:20+00:00

I have a model, for example : class Account < ActiveRecord::Base before_create :build_dependencies def

  • 0

I have a model, for example :

class Account < ActiveRecord::Base

  before_create :build_dependencies

  def build_dependencies
    # use nifty params to build this related object
    build_nifty_object(params)
  end

The initial params are sent in through a hidden form tag on the Account#new form.

But there’s no reason/need for these params to be saved to the account model. I just need them in the NiftyObject model.

Is there a clever way to pass these params to the before_create method ? Or any other alternatives that might accomplish the same task?

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-06T13:24:21+00:00Added an answer on June 6, 2026 at 1:24 pm

    You can use instance variables to workaround this, and do +1 step from the controller:

    class Account < ActiveRecord::Base
    
      before_create :build_dependencies
    
      def assign_params_from_controller(params)
        @params = params
      end
    
      def build_dependencies
        # use nifty params to build this related object
        build_nifty_object(@params)
      end
    

    In the controller:

      def Create
        account = new Account(params)
        account.assign_params_from_controller( ... )
        account.save   # this will trigger before_create
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a Model like the following example class Person < ActiveRecord::Base has_many
It seems simple, in my model I have: class CustomerAccount < ActiveRecord::Base acts_as_url :name
I have a model: class Example(models.Model): unique_hash = models.CharField(max_length=32,unique=True) content = models.FileField(upload_to='source',blank=True,verbose_name=HTML Content File)
I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other
I have a db.Model that has a db.UserProperty. For example: class Photo( db.Model ):
I'm a Django newbie who needs your help Have this database model: class Record(models.Model):
I have a model with a custom method. Here's the example: class MyModel(models) id
In the example below, I have a model Proof which contains a foreign key
I have a parent model that has many child models, for example: App.Blog =
So for example ... Lets say I have a Posts model and a News

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.