1

データを送信したユーザーのテーブルから情報を表示できます。テーブルからすべてのユーザー情報を表示する方法を設定できないようです。

index.html.erb:

#This gives undefined local variable or method 'bio'. bio.content works on the user page if signed in and shows data from the user only.

<%= bio.content.all %>

bio_controller.rb:

            def show
            @bio= User.all
        end

user_controller.rb:

  def show
    @bio = current_user.bio.build

プロファイルからサインインしたユーザーのデータのみを表示することを許可するのではなく、データベースからすべてのバイオ情報を表示できるように、私が欠けているものを正確に示すことができますか?

4

1 に答える 1

2

ビューで必要です@bio.content.all。そして、おそらくいくつかの HTML を使用して構造化する必要があります。

if @bio
   @bio.content.all.each do |b|
      <!-- some HTML to show the `b` record -->
   end
end
于 2013-09-24T20:17:45.237 に答える