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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:48:51+00:00 2026-06-09T15:48:51+00:00

My app has a type, which is carried consistently through the flow and the

  • 0

My app has a type, which is carried consistently through the flow and the type is numbered 1, 2, 3 or 4.

In my application_controller.rb, I have the following code:

before_filter :record_type

and then below that, in protected:

def record_type
 field should go here = @type
end

I’m confused about how to note the field in the User table. It is just User.type = @type?

  • 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-09T15:48:53+00:00Added an answer on June 9, 2026 at 3:48 pm

    You’ll have to get your particular record you want to edit first. If it goes on the user, if you have a helper method like current_user (which devise and similar authentication systems provide), you can just use that.

    You just want to do current_user.type = @type

    But this isn’t really a before_save with what you have now. If you’re trying to store it when you save the User record, move your filter to the User model. Do something like

    before_save :add_type_to_user
    
    def add_type_to_user
       self.type = your_type_value_here
    end
    

    How you get your type value to the model will depend on where you’re getting it from. You can use a before_filter in application_controller to set a @@ variable. I use this trick sometimes to get the current user when I’m in a model. You just need to make a getter and setter for the @@ variable. THen you’d just do something like:

    self.type = User.get_current_type
    

    or something like that.

    I know it’s very rough, but I hope this points you in the right direction.

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

Sidebar

Related Questions

ISQL-SE 4.10.DD6 (DOS 6.22): My app has the following SQL script (CODE REVIEW) which
I have a magazine type app which has TextViews on each of the pages,
My app has a form which uses checkboxes to sort results by type and
I have a c# windows app project which has to open IE, navigate to
I have an MVC app which has a Tab Panel rendered as the only
I have an MVC 3 web app that has an Action which I need
My app has an options menu that is available in almost all Activities, which
My app has an expensive service method, results of which must be 1) checked
My app has several buttons which trigger different events. The user should NOT be
I have a web app that has lots of pages with a URL of

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.