Comments (8)
Hmm, that is weird -- could you check if STI uses a _type
method of the model? Previously, both type
and _type
methods were defined for the model instance in question.
from retire.
Any news on this?
from retire.
I don't believe STI uses _type but something happens when you include Tire::Model::Search that breaks the type handling. I'll take a deeper look sometime next week and see if I can figure out what's going on.
from retire.
Ah yes. I believe rails does use _type internally. there may be other stuff going on as well.
In my model:
class Image < Asset
end
without tire:
> Image.first._type
←[1m←[35mImage Load (1.0ms)←[0m SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN ('Image') LIMIT 1
=> "Image"
with tire:
> Image.first._type
←[1m←[35mImage Load (1.0ms)←[0m SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN ('Image') LIMIT 1
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/tire-0.3.1/lib/tire/model/search.rb:199:in `block (2 levels) in <class:InstanceMethodsProxy>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/tire-0.3.1/lib/tire/model/search.rb:259:in `_type'
from (irb):66
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:35:in `require'
from script/rails:35:in `<main>'
also:
> Image.first
←[1m←[36mImage Load (0.0ms)←[0m ←[1mSELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN ('Image') LIMIT 1←[0m
(Object doesn't support #inspect)
=>
from retire.
Hmm, _type
should not be added when the model has that method already defined. Could you create a Rails template which generates some STI scaffolds etc, so I have less work with recreating that?
from retire.
Any news? Neither #type
nor #_type
really should be added to your model on 0.3.
from retire.
I added a basic rails app that shows the problem here:
https://github.com/aaronchi/tire-sti
Tire is defined on the Image model which is a child of the Asset model. If you go into console and try to create an image
Image.create(:title => 'Something')
You get the error I was describing above:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/tire-0.3.2/lib/tire/model/search.rb:199:in `block (2 levels) in <class:InstanceMethodsProxy>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/tire-0.3.2/lib/tire/model/search.rb:259:in `_type'
If you move the tire index to the Asset model, creation works fine because it doesn't conflict with the STI type variable.
from retire.
OK, thanks for being stubborn on this. I have found the offending code and moved the the unneccessary methods into Model::Persistence
. The sample app works now.
from retire.
Related Issues (20)
- empty array HOT 2
- Elasticsearch 1.2.1, empty hash should be removed. HOT 5
- T
- Can I use regexp query via tire? HOT 1
- Persistence module does not provide updating a record. HOT 2
- "uninitialized constant" error on import rake task HOT 3
- Sort by field value other model (table)
- How can we use tire with multitenant app?
- Timeout option on activerecord? HOT 1
- Boost hits based on date HOT 2
- is there a way to use tire with zeus-parallel_tests?
- Custom Mapping on Hstore Columns
- Elasticsearch(0.90.9) failed to download 230K records(~80mb), with Tire gem(0.4.2).Below was the error message
- Elasticsearch(0.90.9) failed to download 230K records(~80mb), with Tire gem(0.4.2).Below was the error message
- import:all tasks: models load HOT 1
- Regarding nested query
- Support to `search_type: scan` HOT 1
- Ordering doesn't work without RoR shutdown HOT 1
- d
- Querying Association Trouble? 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 retire.