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?
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
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:
or something like that.
I know it’s very rough, but I hope this points you in the right direction.