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 7014661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:33:01+00:00 2026-05-27T22:33:01+00:00

GIST is here: https://gist.github.com/1553371 These are the models I have: class Character < ActiveRecord::Base

  • 0

GIST is here:
https://gist.github.com/1553371

These are the models I have:

class Character < ActiveRecord::Base
  has_many :weapons
end

class Weapon < ActiveRecord::Base
  belongs_to :character
end

and this is what my view in HAML looks like:

= form_for(@weapon) do |f|
  %ul.fields
    %li
      = f.label :character
      = collection_select :weapon, :character_id, Character.all, :id, :name, {:prompt => 'Please Select a Character.'}

but I keep getting this error:

undefined method `character_id' for #<Weapon:0x007f9033232088>

I’ve attempted using a string for character_id, that also didn’t work. The form renders with :character, but then of course it won’t save back since it needs the id.

  • 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-27T22:33:02+00:00Added an answer on May 27, 2026 at 10:33 pm

    Your code looks fine, it’s likely that you don’t have a character_id field on your weapon model. If you do then you have pending migrations that need to be run.

    You can check the current state of your database by looking at db/schema.db it will show if you have the character_id column or not.

    You can run your migrations using rake db:migrate then use rake db:test:prepare to update your test database as well.

    If it’s not working after running migrations then you’ll need to create one, should look something like:

    # db/migrations/add_character_id_to_weapons.rb
    class AddCharacterIdToWeapons < ActiveRecord::Migration
      def change
        add_column :weapons, :character_id, :integer
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my (censored) config/deploy.rb: https://gist.github.com/eedf6c976f632c1242cf For some reason, any changes to my assets,
I have 2 python scripts https://gist.github.com/2233477 . rsgen.py generates random inputs for use in
In the code available here : https://gist.github.com/1338861 if I would include the code of
Here is a link to my color theme that causes the problem https://gist.github.com/3d8cc59cbc1c7f87817f Does
Full implementation is here https://gist.github.com/1306491 I'm using struct with implicit casting to implicitly convert
I've written up a minimal example of this. The code is posted here: https://gist.github.com/1524725
UPDATE : The full site code is here - https://github.com/eWizardII/PeerInstruction I have the following
I learned of gist.github.com from Mozilla Ubiquity , and have been using it to
I just posted this to a gist: https://gist.github.com/2228570 var out = ''; function doWhat(){
UPDATE 9th june 2012: Setup with mongoid 3.0.0.rc at heroku, see this gist: https://gist.github.com/2900804

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.