new method initializing a property

Hello,

Something really simple doesn't seem to be happening for me.

I have a class called User, I'd like to set a property called "role" at
the time the new form is called. In users_controller I have the
following

def new
@user = new User
@user.role = "Non-Admin"
end

by the time the form posts to the create method, the @user.role is nil.
I tried passing it through via a hidden_field_tag like this:

hidden_field_tag :role, @user.role

but that doesn't seem to worth either.

TIA

GP

Ilan,

Thank you very much for replying. I understand better how to
instantiate the object now, however just that didn't seem to fix my
problem. I'm guessing from your reply that you're still recommending
hidden fields to hold the value. My concern is that someone can
manipulate HTML and change the hidden value to gain access.

Thanks,

GP

Ilan Berci wrote:

@GP -- both your solution and Ilan's should have the same net result,
though Ilan's is the preferred "Rail's Way" of doing things.

I suspect that the problem lies in your view. If you post that we
might be able to offer more help.