実際には、ユーザーのプロフィール ページ (実際の Twitter にあるものと同様) を作成したいだけで、このページに、フォローすることを選択したすべてのユーザーからのツイートを表示したいと考えています。
私がやろうとしていることは次のとおりです。
def profile
if current_user
@tweet = Tweet.new
all_ids = current_user.followeds.map(&:id).push(current_user.id)
@tweets = Tweet.find_all_by_user_id(all_ids)
else
redirect_to root_path
end
end
「プロファイル アクション」は UsersController にあります。
私の routes.rb ファイル:
devise_for :users, :controllers => { :registrations => "registrations" }
resources :users, only: [:show]
resources :tweets
resources :relationships, only: [:create, :destroy]
root to: "home#index"
get '/profile', to: 'users#profile', as: 'profile'
今、localhost:3000/profile にアクセスすると、次のように表示されます:-
UsersController#profile の NoMethodError
未定義のメソッド `find_all_by_user_id' #
この問題を解決するにはどうすればよいですか? さらにコードが必要な場合はお知らせください。前もって感謝します。