初心者の質問はこちら。ネストされたフォームに mongoid、rails 3.2、nested_form を使用しています。
私はそのProfile
モデルを持っていembeds_many :services
ます。ネストされたフォームを使用しており、データベースに正常に保存できました。ただし、埋め込まれたドキュメントを自分のページに表示する方法がわかりません。これは、パズルの最も簡単なピースのようです。以下は私のデータベースがどのように見えるかです:
{ "_id" : ObjectId( "507d6fc757299e4a0c000002" ),
"biz_name" : "Shop Co",
"services" : [
{ "_id" : ObjectId( "508c066a57299ef138000008" ),
"s_and_p_service_description" : "what a great pie",
"s_and_p_service_title" : "Pie" },
{ "_id" : ObjectId( "508c079357299ef138000009" ),
"s_and_p_service_title" : "Fruit",
"s_and_p_service_description" : "what a great fruit" } ],
"updated_at" : Date( 1351354259379 ),
"user_id" : ObjectId( "507d6fc757299e4a0c000001" )
}
私はこのようなものがそれを行うだろうと思った:
<% @profile.services.each do |service| %>
<%= @profile.services.s_and_p_service_title %>
<% end %>
しかし、私は次のエラーが発生します:
undefined method `s_and_p_service_title' for #<Array:0x007fa22a643c18>
私は何を間違っていますか?