ruby on rails – Adding radio buttons in the new currency registration form

The My Ruby on Rails application uses Currency for user authentication. Although I had no trouble adding fields to the default registration form, I am a novice and have not had any luck with radio buttons.

Each :user is a :teacher or :student (the user table is self-attached, in fact, on this basis). The current work registration therefore requires the registrant to enter "student" or "teacher" in the "Position" text field. Naturally, even if it is functional, it is not user-friendly, which is why I would like to replace this text field with two radio buttons.

What I've tried

in the utilisateurs.rb model, I've added a constant:

POSITIONS = [ 
  ["student", "Student"], 
  ["teacher", "Teacher] 
]

AT currency / registrations / new.html.erb I've changed the field's code to:

    
<%= f.label :position, 'Position', :class => & # 39; position button & # 39;%>
<%= f.collection_radio_buttons(:position, @positions_collection, :first, :last) %>

And then I went to the controller. To my knowledge, if Currency was not part of my application, I would call the POSITIONS constant in utilisateurs_controller.rb so:

def new
@user = User.new
@positions_collection = User :: POSITIONS
end

However, the generated automatically utilisateurs_controller.rb with Currency starts with nothing in def new but instead seems to rely on custom methods at the bottom of the file to manage new users:

        def resource_name
:user
end

resource def
@resource || = User.new
end

def resource_class
User
end

mot_mapping def
@devise_mapping || = Currency.mappings[:user]
  end

So I started experimenting, starting with simply adding @positions_collection = User :: POSITIONS at def new. Reloading the registration page returned the following error: "NoMethodError in Currency: Registrations # new
[snip] where line 30 is thrown: undefined method & # 39; map & # 39; for nil: NilClass "This error keeps coming back, no matter where I tried to paste @positions_collection = User :: POSITIONS in the controller, even in custom methods and even trying in combination with @user = User.new.

(Line 30 refers to <%= f.collection_radio_buttons(:position, @positions_collection, :first, :last) %> in the view file, which suggests @positions_collection is the stumbling block, I bet.)

Does anyone have any ideas on how to proceed?