ruby on rails - @ is not allowed as an instance variable name -


i working on project mongoid , rails. here 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 error being returned is:

@' not allowed instance variable name (nameerror) ./app/controllers/groups_controller.rb:5:in `new' 

i can't seem find googling around issue, appear issue lies has_and_belongs_to_many relationship, not certain.

any ideas appreciated.

thanks

the issue was misunderstanding has_and_belongs_to_many. have resolved issue removing that!

thanks guys comments.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -