Comments (3)
Ok I see now you are taking a more explicit approach to schema definition. My original request still stands because its a pretty kickass feature,
In the meantime you should know that your polymorphic columns are not working (there are no specs for this relation apparently)
This works fine:
class Post < ActiveRecord::Base
col :title
col :author, :as => :belongs_to
timestamps
end
This does not:
class Post < ActiveRecord::Base
col :title
col :author, :as => :belongs_to
col :postable, :as => :polymorphic
timestamps
end
Here's the trace:
NoMethodError: undefined method `polymorphic' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000102ad47d0>
from /Users/me/.rvm/gems/ruby-1.9.3-p0/bundler/gems/mini_record-8683b648bc76/lib/mini_record/auto_schema.rb:31:in `block in col'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/bundler/gems/mini_record-8683b648bc76/lib/mini_record/auto_schema.rb:30:in `each'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/bundler/gems/mini_record-8683b648bc76/lib/mini_record/auto_schema.rb:30:in `col'
from /Users/me/apps/minirecord/app/models/post.rb:5:in `<class:Post>'
from /Users/me/apps/minirecord/app/models/post.rb:1:in `<top (required)>'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:456:in `load'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:456:in `block in load_file'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:455:in `load_file'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:342:in `require_or_load'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:489:in `load_missing_constant'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:181:in `block in const_missing'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:179:in `each'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:179:in `const_missing'
from (irb):1
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in `start'
from /Users/me/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from mini_record.
I've actually got some of this working now. Expect a patch soon...
from mini_record.
mmm, now with autocreation of columns from relationships isn't really necessary btw, due to tabledefinition limits you should be able to do:
class Foo < ActiveRecord::Base
schema do |s|
s.references :tagger, :polymorphic => true
s.references :taggable, :polymorphic => { :default => 'Photo' }
end
end
from mini_record.
Related Issues (20)
- Issue about primary keys HOT 2
- ActiveRecord - Abstract class bug. HOT 1
- mini_record incompatible with Rails 4.0 HOT 4
- Idea for handling changing column names HOT 6
- macro facility - useful/interesting? HOT 3
- sqlite3 rewrites the table on every auto_upgrade HOT 2
- Problems with SQLite HOT 2
- MiniRecord don't work without logger HOT 4
- has_and_belongs_to_many join table name issues HOT 1
- wrong table name. bug introduced in my last PR HOT 1
- auto_upgrade! fails because of attempting to add duplicate indexes
- Auto changing column type don't work on PostgreSQL HOT 5
- auto_upgrade! sometimes breaks has_and_belongs_to_many associations
- Partial indexes for PostgreSQL?
- PostgreSQL limitless columns? HOT 3
- how to use mini_record in sinatra?
- "Unsupported number of args for ActiveRecord::ConnectionAdapters::TableDefinition.new() (ArgumentError)" HOT 2
- PostgreSQL booleans not supported HOT 1
- Not related: GoTasks for Mac
- auto_upgrade! NameError: no member 'limit' in struct HOT 2
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 mini_record.