How to access virtual attributes in the model

I’ve got an artist form. In this form I’ve got attributes that do not
exist in the model that the form belongs to. However, I would like to
submit these values for later processing.

My virtual attributes in the form are:

  <%= f.label :foobar %>
  <%= f.text_field :foobar %>

In the artist model, I created a getter:

def foobar
end

When the form is submitted, I am able to access the value of the
virtual attribute by doing, for example: puts params[:artist][:foobar]
in the controller (in the create method):

def create
@artist = Artist.new(params[:artist])

# return the value of the virtual attribute
puts params[:artist][:foobar]
...

end

I would like to do the same thing in the model? How can foobar be
accessed in the model? Or is this not possible?

I might be missing something but it should be as simple as using the
name of the method:

‘self.foobar’ or ‘foobar’ should return whatever the method returns.

On Oct 8, 1:54 am, Christian F. [email protected]