Closed cobraextreme closed 11 years ago
Can you give an example?
Will neoidable auto_index: false
(like Sunspot's) + manual record.neo_save
make sense?
Sure, my example use case is that I have some records that have to be approved by an admin before being visible. I'd like it if there were a way to tell neoid to only make a node for those records when approved? = true
. Right now I have nodes for all records and just filter out the unapproved ones later when querying neo. It works but feels a little dirty.
I'm kind of imagining something like this:
neoidable do |c|
c.field :name
c.create_node_when {|model| model.approved?}
end
Or just c.neo_when(true)
?
I'm not sure that doing a manual record.neo_save
would be an easy way to accomplish this, but maybe I'm thinking about it wrong.
I think that a better approach is "disable all auto-node creation unless i tell you"
Then you'll be able to
class Seomthing < ActiveRecord::Base
include Neoid...
neoidable auto_index: false, ...
after_save :save_neo_node_if_needed
def create_neo_node_if_needed
neo_save if approved?
end
end
I'll add it to the todo list.
I see what you mean. That would work great for me.
See latest changes. v0.1.1 supports auto_index: false
.
Awesome, thanks! This is really helpful.
I am interested in having the neoidable configuration be conditional, so that for example a node is only created/updated/deleted given some condition on a model field. I'd be happy to give it a whirl at some point if this makes sense.