Comments (3)
You might be able to avoid the error you're seeing by creating dummy local models within the migration, matching the old and new model names.
class CreateTaggedObjects << ActiveRecord::Migration
class TaggedObject << ActiveRecord::Base; end
class TaggedObjectChild << ActiveRecord::Base; end
def change
create_table :tagged_objects do |t|
# usual stuff here
end
end
end
It's worth mentioning that this is an order-of-operations issue: you are creating models for tables which don't exist yet. This is not isolated to the acts_as_relation gem, and can creep up with other complex Rails configurations. Even renaming a table can cause the same problem.
Even if the structure is still in flux, you should at least generate a migration that creates the table. You just need a placeholder, Rails shouldn't complain after that.
To avoid that landmine when I am laying out my models, I generally follow a 2-step dance:
- Run
rails g model
to give me a model and accompanying migration - Run
rails g migration
to make any modifications to the table created in Step 1.
This only works if your Rails generator configuration is set up to create migrations along with models, so double check for setting changes to config.generators
in config/application.rb
.
from acts_as_relation.
Thanks to @BattleBrisket
from acts_as_relation.
Happy to help @hzamani !
from acts_as_relation.
Related Issues (20)
- Extending Devise's User to Roles using acts_as_relation HOT 1
- Cannot instantiate an subclass HOT 3
- Rails 3.2 - .specific is not working? HOT 1
- PG::UndefinedColumn, ActiveRecord::StatementInvalid HOT 1
- Cannot use created_at or any timestamp columns to query: ambiguous column name HOT 2
- Nested form splitting child records across multiple rows HOT 2
- Association field name error (assuming default convension names) HOT 1
- Name of the has_one assiocation HOT 1
- Pen.where(name: "...") doesn't work HOT 1
- Rails 4 + ActiveAdmin compatibility (Migration error) HOT 12
- Dependent Destroy does not work ? HOT 1
- Including a "whole" object in json
- Make record duplication possible
- Saving the parent object doesnt save changes to the child HOT 1
- Move version.rb into acts_as_relation directory HOT 1
- Infinite loop unexistant method/`respond_to?` on `.specific` HOT 1
- PG::Error: ERROR: relation "users" does not exist
- SQL request problem
- Gem dependencies incorrect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acts_as_relation.