{"action":"closed","issue":{"url":"https://api.github.com/repos/ga-wdi-exercises/project2/issues/652","repository_url":"https://api.github.com/repos/ga-wdi-exercises/project2","labels_url":"https://api.github.com/repos/ga-wdi-exercises/project2/issues/652/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-exercises/project2/issues/652/comments","events_url":"https://api.github.com/repos/ga-wdi-exercises/project2/issues/652/events","html_url":"https://github.com/ga-wdi-exercises/project2/issues/652","id":170425617,"number":652,"title":"Trouble with many to many","user":{"login":"zorba-strange","id":19437273,"avatar_url":"https://avatars.githubusercontent.com/u/19437273?v=3","gravatar_id":"","url":"https://api.github.com/users/zorba-strange","html_url":"https://github.com/zorba-strange","followers_url":"https://api.github.com/users/zorba-strange/followers","following_url":"https://api.github.com/users/zorba-strange/following{/other_user}","gists_url":"https://api.github.com/users/zorba-strange/gists{/gist_id}","starred_url":"https://api.github.com/users/zorba-strange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zorba-strange/subscriptions","organizations_url":"https://api.github.com/users/zorba-strange/orgs","repos_url":"https://api.github.com/users/zorba-strange/repos","events_url":"https://api.github.com/users/zorba-strange/events{/privacy}","received_events_url":"https://api.github.com/users/zorba-strange/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-10T14:05:35Z","updated_at":"2016-08-10T15:20:08Z","closed_at":"2016-08-10T15:20:08Z","body":"I got many to many to work once. It joined one member to a competition, listed out his username on the show page for the competition. On the users show page it listed out the competition title that user was a part of. However when i log out and log in as a different user, i can't get that user to join the competition, nor show which competition they are apart of on their show page. \r\n\r\n```\r\n# my membership(join table) controller\r\nclass MembershipsController < ApplicationController                                                                                                          \r\n \r\n   def show\r\n     @membership = Membership.find(params[:id])\r\n     @competition = Competition.find(params[:id])\r\n     redirect_to competition_path(@competition)\r\n   end \r\n \r\n   def create\r\n     @current_user = User.find(session[:user_id])\r\n     @competition = Competition.find(params[:id])\r\n     @membership = Membership.create!({user_id: @current_user.id, competition_id: @competition.id})\r\n     redirect_to competition_path(@competition)\r\n \r\n   end \r\n end\r\n\r\n# competition controller\r\nclass CompetitionsController < ApplicationController\r\n   \r\n   def new\r\n     redirect_to root_path unless @current_user\r\n     @competition = Competition.new\r\n   end\r\n   \r\n   def create\r\n     redirect_to root_path unless @current_user\r\n     @competition = Competition.create!(comp_params)\r\n     redirect_to competition_show_path(@competition.id)\r\n   end\r\n     \r\n   def show                                                                                                                                                   \r\n     @competition = Competition.find(params[:id])\r\n     @membership = Membership.where(competition_id: params[:id])\r\n     @user = User.all\r\n   end\r\n \r\n   def index\r\n     @competitions = Competition.all\r\n   end\r\n \r\n   private\r\n   def comp_params\r\n     params.require(:competition).permit(:title, :start_date, :end_date, :info)\r\n   end\r\n \r\n end\r\n\r\n# competition show page\r\n <div class=\"page_wrapper\">\r\n   <%= link_to \"Join Competition\", membership_path(:action=> :create, :user_id=> @current_user.id, :competition_id => @competition.id) %>\r\n   <h1 class=\"h1_title\"><%= @competition.title %></h1>                                                                                                        \r\n   <p><%= @competition.info %></p>\r\n   <% @membership.each do |member| %>\r\n     <% @user.where(id: member.user_id).each do |user| %>\r\n       <%= user.username %>\r\n     <% end %>\r\n   <% end %>\r\n </div>\r\n \r\n# user controller\r\nclass UsersController < ApplicationController                                                                                                                \r\n \r\n   def new\r\n     @user = User.new\r\n   end\r\n \r\n   def create\r\n     @user = User.create!(user_params)\r\n     session[:user_id] = @user.id\r\n     redirect_to user_path(@user.id)\r\n   end\r\n     \r\n   def show\r\n     @user = User.find(params[:id])\r\n     @membership = Membership.where(user_id: params[:id])\r\n     @competition = Competition.all\r\n   end\r\n \r\n   private\r\n   def user_params\r\n     params.require(:user).permit(:username, :password, :photo_url, :bio)\r\n   end\r\n \r\n end\r\n\r\n# user show page\r\n\r\n <div class=\"page_wrapper\">\r\n   <h1 class=\"h1_title\"><%= @user.username %></h1>\r\n   <img class=\"profile_pic\" src=\"<%= @user.profile_url %>\" alt=\"profile picture of <%= @user.username %>\">                                                    \r\n   <h3 class=\"h3_title\"><%= @user.bio %></h3>\r\n   <% @membership.each do |membership| %>\r\n     <% @competition.find(membership.competition_id) do |competition| %>\r\n       <%= competition.title %>\r\n     <% end %>\r\n     \r\n   <% end %>\r\n   \r\n     \r\n </div>\r\n```"}}
{"actor":{"display_login":"andrewsunglaekim"}}