-
Notifications
You must be signed in to change notification settings - Fork 899
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
"error while trying to load the gem" when database does not exist, or connection not yet established #740
Comments
PaperTrail requires your database to exist and to have a |
Can you provide a full stack trace? |
Thanks for the response.
I have on Rakefile:1
|
@jaredbeck, is this not an inconvenience. Imagine a situation where a new developer joins your team but unable to setup his development environment using the rake task. |
The commit history:
It looks like the simplest possible solution to #465 would've been to only add The only other place this config is used, is in I think it would make sense that such a method would fail if the table is missing, so the check may need to be left there. But then again, I'm not sure I'm sold on this decision from #465 to have Paper Trail not raise an error when you try modifying (deleting) data. It seems like if something isn't set up correctly Paper Trail should notify you. The problem described here: #465 (comment) seems to be completely unrelated -- the fact that they didn't set up the version_associations table is the issue, not the fact that they're using a custom versions table for that model. The other example on that ticket is a |
So unless there's something I'm not understanding, we should either remove all the checks and let the error come through (it would only happen when destroying or creating records), or we should wrap the error with a more useful message, pointing people to some documentation. |
It sounds like as it is, it's impossible to start Rails / Sinatra with a missing database because the |
Testing with my Rails 4.2 app, it appears that when the database doesn't already exist @josisusan do you have something in your In my opinion,
|
To be fair, this has nothing to do with Sinatra or Rack. This is due to the fact that you are requiring the gem before setting up your database. Try changing your Rakefile accordingly:
If you're using the Sinatra ActiveRecord extension, that database initializer could look like this]: require "sinatra/activerecord"
set :database, {adapter: "sqlite3", database: "foo.sqlite3"} Then at the top of your Sinatra file you can should be able to add your We might be able to at some point add some code to lazily evaluate whether the database has the setup expected in cases where ActiveRecord is not connected initially, that would be ideal probably. That being said I don't think I would call this a bug either. |
@seanlinsley its working fine for rails application. I have created repo based on sinatra which will generate same error on paper_trail(>= 4) if we run: $ bundle exec rake -T |
Thanks Susan. I tried your repo (at josisusan/cafe_app@30d7fa7) and I can confirm that it fails to load PT:
Given this new information, I'll label this as a confirmed bug. Thanks, Susan! You know, if we just required everyone to have the |
Fixed by #785 |
Hi,
I have a fresh sinatra application on which paper_trail has been included. After I bundled it and ran
It gave me error:
If I use version below 4.0.0 (i.e. 3.0.9), it works fine. But after I upgrade it to 4 or above, it gives me same error as above.
The text was updated successfully, but these errors were encountered: