trying to setup a basic join :has_many :through
I have a basic Users / Memberships / Groups

I want a user to navigate to the Groups#show if the user is logged in they are shown a "Join" button, if the user is not logged they are offered a link to the login/registration.

I can handle the if logged in stuff using devise.  The piece I don't know how to do is the Join...   The real piece I am trying to figure out is the view code I think. I don't need anyone to write the code.   just point me in the right direction and I'll figure it out... 

I have all the basic code for this setup.  The the tables are created, the models exist... the relationship is instantiated.

My current membership controller

    def create
      @membership = current_user.memberships.build(:group_id => params[:group_id])
      if @membership.save
        flash[:notice] = "You have joined this group."
        redirect_to :back
      else
        flash[:error] = "Unable to join."
        redirect_to :back
      end
    end

    def destroy
      @membership = current_user.memberships.find(params[:id])
      @membership.destroy
      flash[:notice] = "Removed membership."
          redirect_to :back
    end
  end

any direction would be great
trying to setup a basic join :has_many :through
===

I have a basic Users / Memberships / Groups

I want a user to navigate to the Groups#show if the user is logged in they are shown a "Join" button, if the user is not logged they are offered a link to the login/registration.

I can handle the if logged in stuff using devise.  The piece I don't know how to do is the Join...   The real piece I am trying to figure out is the view code I think. I don't need anyone to write the code.   just point me in the right direction and I'll figure it out... 

I have all the basic code for this setup.  The the tables are created, the models exist... the relationship is instantiated.

My current membership controller

    def create
      @membership = current_user.memberships.build(:group_id => params[:group_id])
      if @membership.save
        flash[:notice] = "You have joined this group."
        redirect_to :back
      else
        flash[:error] = "Unable to join."
        redirect_to :back
      end
    end

    def destroy
      @membership = current_user.memberships.find(params[:id])
      @membership.destroy
      flash[:notice] = "Removed membership."
          redirect_to :back
    end
  end

any direction would be great