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

  • SEARCH
  • Home
  • 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 4554692
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:07:15+00:00 2026-05-21T17:07:15+00:00

I am having that problem that my model dont want to save. I have

  • 0

I am having that problem that my model dont want to save. I have a token field input for tags.
I have followed this guide for the token input: http://railscasts.com/episodes/258-token-fields

I get this error when I try to create a new konkurrancer:

NoMethodError in Admin/konkurrancersController#create

undefined method `class_name' for nil:NilClass

Rails.root: C:/Rails/konkurranceportalen
Application Trace | Framework Trace | Full Trace

app/models/konkurrancer.rb:15:in `tag_tokens='
app/controllers/admin/konkurrancers_controller.rb:48:in `new'
app/controllers/admin/konkurrancers_controller.rb:48:in `create'

http://pastie.org/1834194

Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"yo7wcAQl81tx3zZpPP44ENPYzYRZLpgyYKY+HK3yFKM=",
 "konkurrancer"=>{"name"=>"Vind en rejse",
 "banner2"=>"asdasd",
 "tracking"=>"sadasd",
 "vaerdi"=>"12222",
 "tid"=>"1 min",
 "tag_tokens"=>"1",
 "bedom"=>"2",
 "kategori_id"=>"9",
 "form"=>"Nyhedsbrev",
 "partner"=>"Iqmedier",
 "udtraekkes(3i)"=>"30",
 "udtraekkes(2i)"=>"4",
 "udtraekkes(1i)"=>"2011",
 "udtraekkes(4i)"=>"08",
 "udtraekkes(5i)"=>"26",
 "arrangeor"=>"",
 "note"=>""},
 "commit"=>"Opret konkurrence"}

My konkurrancer model:

class Konkurrancer < ActiveRecord::Base
attr_accessible :name, :tag_tokens
  has_many :tagsmenus
  has_many :tags, :through => :tagsmenus
attr_reader :tag_tokens

  def tag_tokens=(ids)
    self.tag_ids = ids.split(",")
  end

end

My tag model:

class Tag < ActiveRecord::Base
has_many :tagsmenus
has_many :konkurrancers, :through => :tagsmenus
has_friendly_id :name, :use_slug => true
before_save :assign_cached_slug, :unless => :cached_slug?

protected
  def assign_cached_slug
    self.cached_slug = self.name.gsub(/\s+/, '_').gsub(/[^\w\-]/, '')
  end

end

My tagmenu model:

class Tagsmenu < ActiveRecord::Base
end

My controller:

def new
@konkurrancer = Konkurrancer.new  
respond_to do |format|
format.html # new.html.erb
format.xml  { render :xml => @konkurrancer }
end
end
  # POST /konkurrancers
  # POST /konkurrancers.xml
  def create
    @konkurrancer = Konkurrancer.new(params[:konkurrancer])

    respond_to do |format|
      if @konkurrancer.save
        format.html { redirect_to(:admin_konkurrancers, :notice => 'Konkurrancer was successfully created.') }
        format.xml  { render :xml => :admin_konkurrancers, :status => :created, :location => @konkurrancer }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @konkurrancer.errors, :status => :unprocessable_entity }
      end
    end
  end

I have created the join table and the model and also added the relation to my tag model.

  • 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-05-21T17:07:16+00:00Added an answer on May 21, 2026 at 5:07 pm
    class Tagsmenu < ActiveRecord::Base
      belongs_to :konkurrancer
      belongs_to :tag
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails controller I dont ever want to set a cookie. I
I'm having a strange problem with anchor tags shifting divs upwards which is causing
This is not a homework problem, though it is a work problem. Where months
I'm adding a password reset feature to my Rails application that uses Authlogic. I
I have a Ruby on Rails (2.3.5) application and an APE (Ajax Push Engine)
Can someone recommend a reliable HTML tree control that also supports tree manipulation? I
I'm trying to implement a Widget control that exists on every page in the
This is my first WordPress 3 site. I'm currently developing a site for a
I'm making a vibrate toggling widget (in fact, its first version is already in
For reasons which are somewhat unavoidable (lots of legacy code, compatibility, design needs) I

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.