Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8653177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:28:50+00:00 2026-06-12T14:28:50+00:00

I have tried to get this working, looked at multiple tutorials, questions on here

  • 0

I have tried to get this working, looked at multiple tutorials, questions on here tried different things for about a week now and I can’t get the view to work correctly.

I have teams of users. A team has_many users and a user belongs_to a team (one team at a time). I know the association works because I got it working using the console (with some help there). I’m not sure how to get it working in the view. Below is the code, please let me know if more is needed.

What am I missing?

_join_team_button

<%= form_for(@user) do |f| %>
  <%= f.submit "Join Team", class: "btn btn-large btn-primary" %>
<% end %>

Team Show Page

<%= render 'shared/join_team_button %>

Teams Controller

def show
  @team =  Team.find(params[:id])
  @team_members = @team.users
  @user = current_user.users.build if signed_in?
end

Users Controller

def show
  @user = User.find(params[:id])
  @teams = @user.team
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:28:52+00:00Added an answer on June 12, 2026 at 2:28 pm

    I figured it out. Still not perfect, but it gets the association working. The team, and the user were already created, I just needed to establish the association, so the build method would not have worked. Here’s what I have:

    View:

    <%= form_for(@user) do |f| %>
    <%= f.hidden_field :team_id, :value => @team.id %>
      <%= f.submit "Join Team", class: "btn btn-large btn-primary" %>
    <% end %>
    

    Teams Controller:

    def show
      @team =  Team.find(params[:id])
      @team_members = @team.users
      @user = User.find(params[:id]) if signed_in?
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried and failed to get this working. Basically I am trying to
Hello you naughty code animals.. I have tried to get this code to work,
Cant get this script to work with my menu really have tried everything any
This might get a little confusing as I have tried everything to make this
I cannot get smooth lines for this graph. I have tried anti aliasing, increasing
I have google'd it, and tried some examples, but I always get stuck. This
Let me start out by saying I have tried this and looked at this
Ok so I have looked at many posts on how to get DI working
I have looked around for a way of implementing this. Here is a pseudocode
Does file_get_contents maintain line breaks? I thought it did but I have tried this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.