Fields_for and table which has underscore

Hello.
I’m trying to do like this:

user.rb

class User < ActiveRecord::Base
has_one :user_profile
accepts_nested_attributes_for :user_profile
end

user_profile.rb

class UserProfile < ActiveRecord::Base
belongs_to :user
end

#app/views/users/_form.html.erb
<%= form_for @user do |user_form| %>
<%= user_form.fields_for :user_profile do | user_profile_form | %>
<%= user_profile_form.text_field :favorite_food %>
<% end %>
<% end %>

but it doesn’t render user_profile_form at all.
but it does render if user_profile is profile or user_profile ( no
underscore) .
Is this the way of Rails or a bug??

Can anyone teach me the right way to do it?
Thanks

Is this the way of Rails or a bug??

It shouldn’t make any difference. Does the user actually have a
profile/user_profile? (if not the subform wouldn’t be rendered)

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs