I am currently working on a project with mongoid and rails. Here is the code:
class Account
include Mongoid::Document
include Mongoid::Timestamps
field :account_name, type: String
has_many :groups
end
class Group
include Mongoid::Document
field :group_name, type: String
belongs_to :account
has_and_belongs_to_many :groups
end
class GroupsController < ApplicationController
before_filter :require_login, :find_company
def new
@group = @company.groups.new
end
def create
@group = @company.groups.new params[:group]
if @group.save
redirect_to people_path
else
render :new
end
end
private
def find_company
@company = current_account.groups.find(params[:company_id]) if params[:company_id]
end
end
And the error that is being returned is:
@' is not allowed as an instance variable name (NameError)
./app/controllers/groups_controller.rb:5:in `new'
I can't seem to find much googling around for the issue, but it would appear the issue lies with the has_and_belongs_to_many relationship, but I am not certain.
Any ideas would be appreciated.
Thanks