I'm playing with rails 4. I just created very simple test for my model but when I try to execute "rake test:models" I get following error:
C:\rails\project>rake test:models
DL is deprecated, please use Fiddle
rake aborted!
Errno::EACCES: Permission denied # unlink_internal - /tmp/db/new.sqlite3
C:/rails/project/test/test_helper.rb:3:in `<top (required)>'
C:/rails/project/test/models/admin_test.rb:1:in `<top (required)>'
Tasks: TOP => test:models
(See full trace by running task with --trace)
My test database configuration looks as follows:
test:
adapter: sqlite3
database: /tmp/db/new.sqlite3
pool: 5
timeout: 5000
"/tmp/db" is directory where I have full access on my personal laptop.
Any ideas what could be source of this problem?
One way I was able to get around this error was using
rake db:migrate rails_env=test
This generated the necessary migrations on my test.sqlite3
I believe the default setting for rails_env is "dev" but this may vary. I am still very new to rails but I hope this helps.
I had the same problem with my test.sqlite3 table and what worked for me was making a copy of my development.sqlite3 table and renaming it test.sqlite3. I hope this works for you.
Related
...like this: paperclip2active_storage
Update be sure to watch the linked video presentation as the text document does not present all the quirks!
so I installed and configured rails 7 and gem 'mini_magick'. Now I suppose the referenced script will update all my models, views and controllers:
but, when I run it I get error like this:
leder#home-ryzen-desktop:~/Git/gmr_production_heroku$ ruby migration.rb
migration.rb:1:in `<main>': uninitialized constant ActiveRecord (NameError)
migration.rb as described in the referenced link!
How do I do migrate my RoR App?
I have removed development from database.yml and added to storage.yml:
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
amazon:
...
Now I get this error:
leder#home-ryzen-desktop:~/Git/gmr_production_heroku$ bundle exec rake db:create
rake aborted!
ActiveRecord::AdapterNotSpecified: The `development` database is not configured for the `development` environment.
Available database configurations are:
production
/home/leder/.rbenv/versions/3.0.1/bin/bundle:23:in `load'
/home/leder/.rbenv/versions/3.0.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:create => db:load_config
(See full trace by running task with --trace)
How do I migrate this to active_storage?
Follow up question can be found here: Part2
You need to run the migration in the context of Rails. So ruby migration.rb won't work.
You need to generate a migration with bin/rails g migration <migration_name>.
Then once you copy the code into the migration, run bin/rails db:migrate.
P.S. Rails 7 hasn't been released yet. So moving to Rails 7 might be premature since it may still have bugs and many gems may not support it fully
I'm having issues installing the SOLIDUS gem for my rails app. I followed the instructions from GitHub but when i run the command bundle exec rake db:migrate i get the error:
mannay:testsite mannay$ bundle exec rake db:migrate
rake aborted!
PG::ConnectionBad: fe_sendauth: no password supplied
/usr/local/var/rbenv/versions/2.5.0/bin/bundle:23:in `load'
/usr/local/var/rbenv/versions/2.5.0/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I've tried adding username: mannay to my database.yml and even password: but it doesn't work. I thought maybe i've added a password that i don't remember, so i opened postgressapp, and tested
ALTER USER mannay with password 'new_password';
but it doesn't change anything.
Any ideas?
I'm trying to clone the Catarse repository: Git catarse
and I get all the way to the end but once I try to run rake db:seed I get the following error message:
rake aborted!
Errno::ENOENT: No such file or directory # dir_initialize - /Users/'USERNAME'/Desktop/my_websites/crowdfund_test/catarse/tmp/cache/
/Users/'USERNAME'/Desktop/my_websites/crowdfund_test/catarse/db/seeds.rb:116:in `<top (required)>'
Tasks: TOP => db:seed
Do you know why??
I was having the same problem. Then I realized I did not have the directory
/yourPath/catarse/tmp/cache/
Once I created it, seeding worked just fine!
Trying to get my rails up and running but am having a problem. When creating my new rails app on the command line I ran the usual
rails new PhotoApp -d postgresql
Generated my core scaffold. Then generated a model with attributes in the terminal and that was fine. After creating my model I first ran rake db:create and that returned a long log of characters with at the top telling me FATAL: role "PhotoApp" does not exist so then I tried rake db:migrate and that didn't work either returning me
rake aborted!
PG::ConnectionBad: FATAL: role "PhotoApp" does not exist
/Users/##$%^$#/Code/Projects/PhotoApp/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
WTF is going on here?
Thanks for any help.
The error is telling you that Postgres isn't finding your app. What does your database.yml file look like?
I would first run the rake task again, using the --trace as suggested:
rake db:create --trace
That will give you a more verbose tracing, so you can try to isolate the problem.
From experience I can tell you though that 'Roles' in Postgres can be a nightmare. How did you install Postgres on your machine? HomeBrew? The Postgres App?
Please post the full trace, as well as your database.yml file. This will help better assess the problem!
I am just diving into Heroku and have hit a bit of a snag. Whenever I attempt to create my database I am getting the following error.
$ heroku rake db:migrate
rake aborted!
no such file to load -- tasks/rails
/disk1/home/slugs/274236_54c3556_0822-55414a07-d565-459a-9412-67cc0e995790/mnt/Rakefile:10:in `require'
(See full trace by running task with --trace)
(in /disk1/home/slugs/274236_54c3556_0822-55414a07-d565-459a-9412-67cc0e995790/mnt)
I am a little confused about what, exactly, the error message is trying to tell me. I can verify that no file exists called 'rails' or 'rails.rb' in my lib/tasks folder. But just for sanity sake I also used scaffold to create a new RoR app in a clean dirty and verified it's not present their either.
This application was previously running under Rails 2 before I upgraded it to Rails 3. So there is a distinct chance I foo bared something up when I upgraded.
Also, in case it helps, here is the same command as above with tracing enabled:
$ heroku rake db:migrate --trace
rake aborted!
no such file to load -- tasks/rails
/disk1/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/Rakefile:10:in `require'
/disk1/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/Rakefile:10
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/ruby1.8.7/bin/rake:19:in `load'
/usr/ruby1.8.7/bin/rake:19
(in /disk1/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt)
Any clues as to which direction to investigate would be highly appreciated.
Thanks!
EDIT
I am starting to think that Heroku is a red herring. I can attempt to run db:migrate locally and it produces the same errors (obviously with local paths instead of Heroku's paths).
This is a basic application with no special gem dependencies. Here is my Gemfile:
source :gemcutter
gem 'mysql', '2.7'
gem 'rails', '3.0.1'
#gem 'rfacebook'
gem 'sqlite3-ruby', :require => 'sqlite3'
Here is also my database.yml:
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Looks like maybe your Rakefile has some Rails 2 artifacts in it or something. I'd start there, maybe comparing the default Rails 2 and Rails 3 Rakefiles.