Open yuyanegishi opened 5 years ago
user1 = User.find_by(email: "example@railstutorial.org")
user1.active_relationships
=> #<ActiveRecord::Associations::CollectionProxy [#<Relationship id: 1, follower_id: 1, followed_id: 3, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 2, follower_id: 1, followed_id: 4, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 3, follower_id: 1, followed_id: 5, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 4, follower_id: 1, followed_id: 6, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 6, follower_id: 1, followed_id: 8, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 7, follower_id: 1, followed_id: 9, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 8, follower_id: 1, followed_id: 10, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 9, follower_id: 1, followed_id: 11, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 10, follower_id: 1, followed_id: 12, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, #<Relationship id: 11, follower_id: 1, followed_id: 13, created_at: "2018-11-22 01:14:29", updated_at: "2018-11-22 01:14:29">, ...]>
user1.active_relationships.build
=> #<Relationship id: nil, follower_id: 1, followed_id: nil, created_at: nil, updated_at: nil>
user1.following
=> #<ActiveRecord::Associations::CollectionProxy [#<User id: 2, name: "Ashly Cronin", email: "example-1@railstutorial.org", created_at: "2018-11-22 01:14:16", updated_at: "2018-11-22 01:14:16", password_digest: "$2a$10$uey4g1kJQInnaI9Z4O2fy.WRPpnpbjaLtljBS4MkwXm...", remember_digest: nil, admin: false, activation_digest: "$2a$10$5Alb73UJmDRFcQgmTW8./OvRMbG/H6XX1iEjKoUkUzr...", activated: true, activated_at: "2018-11-22 01:14:16", reset_digest: nil, reset_sent_at: nil>, #<User id: 3, name: "Jovany Kiehn", email: "example-2@railstutorial.org", created_at: "2018-11-22 01:14:16", updated_at: "2018-11-22 01:14:16", password_digest: "$2a$10$48aqF/P7S8RnS6p0BCxfVu1DyHd1aBYPFPTDtamcfpQ...", remember_digest: nil, admin: false, activation_digest: "$2a$10$JWyZVRz7oJ.70cgC1eo1/eyHRvFbk1NQRBNWXX1DEgN...", activated: true, activated_at: "2018-11-22 01:14:16", reset_digest: nil, reset_sent_at: nil>, #<User id: 4, name: "Vena Pagac PhD", email: "example-3@railstutorial.org", created_at: "2018-11-22 01:14:16", updated_at: "2018-11-22 01:14:16", password_digest: "$2a$10$P3ao5ofSHGvR9fJOIgeiNe4yNCrKU1owuNJkfS4qFWg...", remember_digest: nil, admin: false, activation_digest: "$2a$10$6ist9IyCE0RbOgGAuH4qWeuuiwHEuGx5poVOHuA/l2I...", activated: true, activated_at: "2018-11-22 01:14:16", reset_digest: nil, reset_sent_at: nil>, #<User id: 5, name: "Chesley Dach", email: "example-4@railstutorial.org", created_at: "2018-11-22 01:14:16", updated_at: "2018-11-22 01:14:16", password_digest: "$2a$10$3NMzIyMEAdnQGCSyyBaE6OwyiO0y4WHtkpBAmXiAR7F...", remember_digest: nil, admin: false, activation_digest: "$2a$10$JeBbZF/1W1JWW1wUmS0rGe4L52fshphRYSdczF6xqz8...", activated: true, activated_at: "2018-11-22 01:14:16", reset_digest: nil, reset_sent_at: nil>, #<User id: 6, name: "Miss Bethel O'Connell", email: "example-5@railstutorial.org", created_at: "2018-11-22 01:14:16", updated_at: "2018-11-22 01:14:16", password_digest: "$2a$10$4xycyOBBcgaQr.yKjoxbFedOlP9bAgQRGhkTRBp6/.M...", remember_digest: nil, admin: false, activation_digest: "$2a$10$q5cfWkVeuaMpT9RVWcYobOA0nXL/OjVCIOeBg/Q6nL....", activated: true, activated_at: "2018-11-22 01:14:16", reset_digest: nil, reset_sent_at: nil>, #<User id: 8, name: "Neva Douglas", email: "example-7@railstutorial.org", created_at: "2018-11-22 01:14:17", updated_at: "2018-11-22 01:14:17", password_digest: "$2a$10$ak.DumvrT5u/TVR.cDu86O8eiiXPUUCQW3BWYn7O480...", remember_digest: nil, admin: false, activation_digest: "$2a$10$Snii4UZITXUAXg.iji2BRuIMmst5bEpdEIcfinRZtlm...", activated: true, activated_at: "2018-11-22 01:14:17", reset_digest: nil, reset_sent_at: nil>, #<User id: 9, name: "Mr. Enrico Goldner", email: "example-8@railstutorial.org", created_at: "2018-11-22 01:14:17", updated_at: "2018-11-22 01:14:17", password_digest: "$2a$10$Nn15RddYgksoL2OZNYKYKerlKJvSLvEoGQOo/NB6GEW...", remember_digest: nil, admin: false, activation_digest: "$2a$10$xuwcO4SCeLGRFrMn9AvqyeR6TacQdnhiMjmRAhwXbxW...", activated: true, activated_at: "2018-11-22 01:14:17", reset_digest: nil, reset_sent_at: nil>, #<User id: 10, name: "Susana DuBuque", email: "example-9@railstutorial.org", created_at: "2018-11-22 01:14:17", updated_at: "2018-11-22 01:14:17", password_digest: "$2a$10$tGRMgXy1XyDV5BRssODcSOCS2qODgugma9SHEtnq9lN...", remember_digest: nil, admin: false, activation_digest: "$2a$10$0qPECPBmgIBFkI/sZ/UZmedjHYUO4XqUCrTOck8RTYf...", activated: true, activated_at: "2018-11-22 01:14:17", reset_digest: nil, reset_sent_at: nil>, #<User id: 11, name: "Braeden Mosciski", email: "example-10@railstutorial.org", created_at: "2018-11-22 01:14:17", updated_at: "2018-11-22 01:14:17", password_digest: "$2a$10$5KYGK0GtOCCN9BHfWrdd.u9T7z5rj7qOvDxOEb0u/XC...", remember_digest: nil, admin: false, activation_digest: "$2a$10$8DFgq6e9galtHQ0ouhru1OeMTjI2zCGiwzc7ymf2/ZY...", activated: true, activated_at: "2018-11-22 01:14:17", reset_digest: nil, reset_sent_at: nil>, #<User id: 12, name: "Marques Feeney", email: "example-11@railstutorial.org", created_at: "2018-11-22 01:14:17", updated_at: "2018-11-22 01:14:17", password_digest: "$2a$10$ql8UugU4BX/PFWwBD3eYOe/bwl2ayfgOEHCQ3GzWUNx...", remember_digest: nil, admin: false, activation_digest: "$2a$10$ixpC1EGYDdOsJ1W3Bik/RO6B94YyP0e5aQT8ADdIKh6...", activated: true, activated_at: "2018-11-22 01:14:17", reset_digest: nil, reset_sent_at: nil>, ...]>
フォローボタンのhtml(app/views/users/_follow.html.erb)
フォローボタンを押した際にサーバーに送信されるメッセージ
フォローボタン押した後のアクション(app/controllers/relationships_controller.rb/)