Having problems creating radio buttons in a form using has_one
Model
Class User
has_one :role
accepts_nested_attributes_for :role
Class Role
attr_accessible :name
belongs_to :user
Controller
@user = build_role
Form for radio buttons
<div class="field">
<% Role.offset(1).all.each do |role_fields| %>
<%= radio_button_tag "user[role_fields_id][]", role_fields.id, @user.role_id == role_fields.id %>
<%= role_fields.name %>
<% end %>
</div>
Getting the error
undefined method `role_id' for #<User id: nil, name: nil, created_at: nil, updated_at: nil>
I'm sure I set up the relationship in the controller, why is this not working?