0

私は今、基本的な裸の骨ソーシャルメディアアプリを構築しています。特定のオブジェクトフィールドにアクセスする方法は?

私はユーザークラスとステータスクラスを持っています。

ステータスごとに、「作成者」(ユーザーオブジェクト)と「サブジェクト」(ステータスがあるユーザーオブジェクト)があります。私はacts_as_taggable_on gemを使ってタグを作成することができました。何が起こるのかは、ユーザーが投稿を作成するときにドロップダウンメニューから別のユーザーを選択することです。選択されたユーザーのid属性が格納されます。

これで、選択したユーザーのプロフィールにリンクしようとしています。これはプロフィールページのステータスを表示する私のコードです。

<% if @statuses %> 
     <% @statuses.each do |status| %> 
     <div class="well"> 
      <%= status.content %> 
      <br></br> 

      #link to user who's associated with the tagId 
      <%= link_to User.find(status.tag_list).profile_name, user_profile_path(User.find(status.tag_list).profile_name) %> 
      <hr /> 
      <%= link_to time_ago_in_words(status.created_at), status_path(status) %> ago 
     </div> 
     <% end %> 
    <% end%> 

これは上記のコードは、改行がある

   <%= link_to User.find(status.tag_list).profile_name, user_profile_path(User.find(status.tag_list).profile_name) %> 

は、誰もがこれで私を助けることはできますか?

+0

「コードブレーク」を定義 –

+0

エラーメッセージを投稿すると便利です – Ren

答えて

0

驚いていない。この行は失敗している:

<%= link_to User.find(status.tag_list).profile_name, user_profile_path(User.find(status.tag_list).profile_name) %> 

カップルのポイント:

  • それは複数行にそれを分離するために少しクリーナーだあなたがしているので
  • 私はあなたの問題があると思われるがありますidの代わりにprofile_nameをuser_profile_pathに渡しますが、私はあなたのルートを見ないと確信できません。

試してみてください。

<% profile_user = User.find(status.tag_list) %> 
<%= link_to profile_user.profile_name, user_profile_path(profile_user.id) %> 
関連する問題