Rails 3 - Nested Forms, using Builder
I have the following:
My Controller:
def new
.
.
@teammembers.each do |teammember|
request = @request_thread.requests.build(:recipient_id => teammember.user_id, :full_name => 'Billy Bob T')
end
My View:
<%= f.fields_for :requests do |builder| %>
<div class="field">
<%= builder.label :full_name %>
<%= builder.check_box :recipient_id, :checked => false %>
</div>
<% end %>
The nested form for request only holds the user_id, not the user.name... Prob开发者_运维百科lem is in the nested form, I need to show the user.name next to the check_box. So I tried adding a virtual attribute in the model (attr_accessor :full_name), so I could use full_name but I can't see to access that in the nested form (inside builder).
Any tips or suggestions from the pros?
Thanks
What about:
User.find(:recipient_id).name
EDIT: I hope i understood your question ..
精彩评论