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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:48:52+00:00 2026-05-23T13:48:52+00:00

I want to alter the data and save it then to the database when

  • 0

I want to alter the data and save it then to the database when using the new / create function of the app.

  • 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-23T13:48:52+00:00Added an answer on May 23, 2026 at 1:48 pm

    You should use active callbacks, as the two other answers stated. The *before_create* is definitely the one you are looking for. Always do that kind of logic in the model, and not in the controller. Rails mantra (one of many) is “thin controller, fat model”, which enable code reuse more easily.

    You can check the active callbacks documentation at :

    http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html

    Also, here is an example of what you want to achieve

    class MyClass < ActiveRecord::Base
        before_create :alter_my_data
    
        def alter_my_data
            # any manipulation you want to do here before saving
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extract data from HTML table using Python script and save it
Need: take in XML and save data to database. Currently using: JAXB to convert
I want to save my canvas into MySQL database (BLOB cell). I have function
I want an adaptable database scheme. But still use a simple table data gateway
I'm making a WinForms app in C#. When I go to create my database
I want to create a signature for a file using OpenSSL. I believe that
Basically I want to alter the boolean value selecting from the table: e.g.: SELECT
I have a URL like /admin/editblogentry?page=3&color=blue I want to alter the 'page' in the
I want to use my iphone to set alter my wireless router settings, and
I need to alter a trigger in sql server 2005 and I want to

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.