-
Notifications
You must be signed in to change notification settings - Fork 19
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
Gracefully handle eager-loading of a Search prior to DB creation #15
Conversation
Changes Unknown when pulling 29a3a18 on mnarayan01:master into * on nathanl:master*. |
I'm not opposed to this change in general, but I don't want to use an inline rescue because it rescues any possible exception that descends from Would you mind changing this to rescue the specific exception you expect? |
Unfortunately, the exception type is going to be adapter dependent (e.g. My initial take is that rescuing That said, I could move the conditional (https://github.com/nathanl/searchlight/pull/15/files#L0L23) to a function, which would allow me (or anyone else) to easily monkey-patch it. |
I see your point. Yeah, I would say to move the conditional to a method: What do you think? |
Somewhat tangentially: I'm wondering if the adapters themselves are worthwhile. Their whole purpose is to keep you from having to define a few boilerplate search methods, which 1) may not be what you want anyway, and 2) could be easily defined by the user en masse using metaprogramming. @mnarayan01, do you think adapters are worth the trouble? @adamhunter, do you still think so? |
Enable users to gracefully handle the eager-loading of a Searchlight::Search class with a call to ::searches prior to DB creation (e.g. during a call to `rake assets:precompile`) by monkey-patching Searchlight::Search::model_has_db_attribute?
Changes Unknown when pulling 6c7f5bd on mnarayan01:master into * on nathanl:master*. |
Updated to use Re: Adapters...I'm not personally using them, but I can see the utility they provide both for people who are completely new to Rails (and don't know how to create the appropriate methods), and people who are familiar with Rails (and don't want to create the methods). That said, it would be nice if they were either moved to different gems (probably more administrative overhead than its worth) or at least not auto-required. The latter would force the user to require them in an initializer or via the Gemfile if desired, but it would totally solve my issue. On a related note, consider the following scenario using a fairly standard (AFAIK) workflow with capistrano:
If the migration added a column (e.g. This doesn't affect me as I'm not using the adapter based methods...just thought I'd throw it out there. |
Gracefully handle eager-loading of a Search prior to DB creation
Merged. Thank you! Also, you make an excellent point regarding the deploy process. I don't like the fact that Searchlight could introduce weird behavior in the name of being helpful. I may rip adapters out or rework them as you suggest at some point. If the code you just contributed disappears with the adapters, please know that you will still have contributed to the project by helping me understand the problems. :) |
Gracefully handle eager-loading a Search when the database/table corresponding to the search object has not yet been created (e.g. when using
rake assets:precompile
).If an exception occurs, we assume that the column does exist, and thus generate a search method which queries on that column. Obviously this search will generate a DB exception if it is ever run.