I'm still a new to Rails, so I'm finding this so frustrating. I'm trying to make a small application as part of a personal project that lets users create and join each others groups.
I've looked on StackOverflow and found two similar questions with answers that don't quite address my scenario (I've even tried using their code and still can't figure out how to go about this).
Those SO links are here:
How do I create a join action between a group and a user?
creating a join action between user and group correctly
What I'm trying to do is figure out the controller actions and erb code that lets users create and join groups. Here are two posts on SO that I've read repeatedly, I tried using their code at one point, but kept getting a 
First argument in form cannot contain nil or be empty
for
<%= form_for(@membership) do |f| %>
That error came from when I was using the membership_controller code in the second SO post I listed. Here are the models I have so far, which I wrote with some help from SO as well.
user.rb (model)
class User < ActiveRecord::Base
    has_many :memberships, :dependent => :destroy
    has_many :groups, :through => :memberships
membership.rb (model)
class Membership < ActiveRecord::Base
    attr_accessible :user_id, :group_id
    belongs_to :user
    belongs_to :group 
group.rb (model)
class Group < ActiveRecord::Base
    has_many :memberships, :dependent => :destroy
    has_many :users, :through => :memberships
I honestly can't figure out how to connect these three models, I've seen examples, tried to think of it for myself for more than a few hours now.
If you can help at all, I will greatly appreciate it. I'm just pulling my hair out trying to get something that I know is simple to do in Rails to work properly.
 
     
    
 
    