Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features aren't declared until Feature model has been required. #1

Open
snikch opened this issue Nov 20, 2011 · 4 comments
Open

Features aren't declared until Feature model has been required. #1

snikch opened this issue Nov 20, 2011 · 4 comments

Comments

@snikch
Copy link

snikch commented Nov 20, 2011

Only tested in development, but until the Feature model has been loaded, any call to a Flip.on? :blarg will raise No feature declared with key :blarg.

If you simply place require 'feature' before a call, then the problem will go away (even for subsequent requests AFTER removing the require 'feature' line).

Is it easy enough to include a load method in Flip, which checks for initialization and requires 'feature' if it's not available?

@pda
Copy link
Owner

pda commented Nov 20, 2011

I've run into this problem too, since renaming the accessor class to Flip but leaving the model class as Feature.

It makes me think that declaring the features inside the Feature < ActiveRecord::Base class is totally wrong.. especially as DatabaseStrategy is just one optional strategy.

I'm thinking of moving the declarations into an initializer, or a config file loaded by an initializer. I guess in the mean time it's possible to create a config/initializers/flip.rb which loads app/models/feature.rb, but it doesn't feel like an ideal solution.

@snikch
Copy link
Author

snikch commented Nov 20, 2011

That's what I was thinking but then you'd need to reload the server on new features correct? That's not that big an issue.

There wouldn't be an issue with getting the current declaration back with an initializer would there, it could still be changed and the strategy could be changed on the fly right?

@d11wtq
Copy link

d11wtq commented Nov 3, 2012

Do you reckon this is a real pain point or have you guys found reasonable workarounds? I'm just trolling your project while I figure out how much work it would be to have it support other ORMs and send a PR.

O/T but do you think this could also be used to facilitate A/B testing (like a strategy that gives users a 50% chance of seeing a feature; maybe even based on something like the last octet of the IP address being odd or even).

@dwbutler
Copy link

The Feature model could be loaded in a Railtie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants