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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:15:05+00:00 2026-06-19T00:15:05+00:00

Rails 3. Here is my code: class AddForAutocompleteInShops < ActiveRecord::Migration def up add_column :shops,

  • 0

Rails 3. Here is my code:

class AddForAutocompleteInShops < ActiveRecord::Migration
  def up
    add_column :shops, :for_autocomplete, :string
  end

  Shop.reset_column_information

  shops = Shop.all

  shops.each do |shop|
    shop.for_autocomplete = %(#{shop.name} #{shop.formatted_address})
    shop.save
  end

  def down
    remove_column :shops, :for_autocomplete
  end
end

Error message occurred:

rake aborted!
An error has occurred, all later migrations canceled:

undefined method `for_autocomplete=' for #<Shop:0x007fba66be7af8>
/Users/abc/Sites/test/db/migrate/20130219121256_add_for_autocomplete_in_shops.rb:11:in `block in <class:AddForAutocompleteInShops>'
/Users/abc/Sites/test/db/migrate/20130219121256_add_for_autocomplete_in_shops.rb:10:in `each'
/Users/abc/Sites/test/db/migrate/20130219121256_add_for_autocomplete_in_shops.rb:10:in `<class:AddForAutocompleteInShops>'
/Users/abc/Sites/test/db/migrate/20130219121256_add_for_autocomplete_in_shops.rb:1:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

What’s wrong with my code? I tested in Rails console it works fine.

Thanks.

  • 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-06-19T00:15:06+00:00Added an answer on June 19, 2026 at 12:15 am

    Your code should be part of either the up or down methods – not in the middle of your migration class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller that renders json. Here's code: class AppLaunchDataController < ApiController def
My code: class User < ActiveRecord::Base belongs_to :university end class University < ActiveRecord::Base has_many
Here's my Model code: class User < ActiveRecord::Base validates :email, :presence => true, :uniqueness
I've a got a method in ActiveRecord::User: def create_user_from_json(user) @user=User.new(user) if @user.save! @user.activate! end
Noob question for Ruby on Rails- here's an example of my situation: If I
Complete new person to Ruby and Rails here... Have tried some tutorials in the
Rails newbie here struggling with a small project. I am creating a simple ship
Rails noob here. I have a rails application with (in this example) three tables.
Rails beginner here.. I have a users resource where I implemented a callback that's
Hoping some learned Rails developers here can recommend an existing Ruby on Rails plugin

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.