rake

How do I make Rake tasks run under my Sinantra app/environment?

喜你入骨 提交于 2019-12-18 12:27:34
问题 I'm using Sinatra, and I wanted to set up some of the convenience rake tasks that Rails has, specifically rake db:seed . My first pass was this: namespace :db do desc 'Load the seed data from db/seeds.rb' task :seed do seed_file = File.join(File.dirname(__FILE__), 'db', 'seeds.rb') system("racksh < #{seed_file}") end end racksh is a gem that mimics Rails' console. So I was just feeding the code in the seed file directly into it. It works, but it's obviously not ideal. What I'd like to do is

rake db:migrate error with mysql2 gem - Library not loaded: libssl.1.0.0.dylib

廉价感情. 提交于 2019-12-18 12:26:21
问题 Getting the following error after running rake db:migrate rake aborted! LoadError: dlopen(/Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle, 9): Library not loaded: libssl.1.0.0.dylib Referenced from: /Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle Reason: image not found - /Users/scott/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle /Users/scott/Google

Error installing gems that use native extensions on Ubuntu, Ruby 1.9.2 via RVM

余生颓废 提交于 2019-12-18 10:55:18
问题 I get an error while trying to install the ffi gem: ~ - 16:54>gem i ffi Building native extensions. This could take a while... ERROR: Error installing ffi: ERROR: Failed to build gem native extension. rake RUBYARCHDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib RUBYLIBDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib /home/mdemare/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems.rb:370:in `bin_path': can't find gem rake ([">= 0"]) with executable rake

invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed in Rails

这一生的挚爱 提交于 2019-12-18 10:01:36
问题 When I run rake db:seed in my Rails app, I'm getting this error: invalid byte sequence in US-ASCII (Argument Error) I just added science_majors and down to my seed file, and now when I run rake db:seed it gives me this error: invalid byte sequence error Why is this, and how can I fix it? part of seeds.rb @college = College.find_or_create_by_name!('University of Pittsburgh') if @college.update_attributes( url: 'university-of-pittsburgh', public: 'Public', years: '4-year', category: 'National

Rake aborted! Uninitialized constant Rake::DSL on Heroku

删除回忆录丶 提交于 2019-12-18 04:18:18
问题 When trying to rake db:migrate on Heroku. I'm getting the following error. rake aborted! uninitialized constant Rake::DSL From what I've gathered this seems to be a bug with Rake 0.9.2. If I do "gem list" locally only Rake (0.8.7) appears to be installed. I've tried adding "gem 'rake', '0.8.7'" to my gem file and running bundle install but then I get the following error. You have requested: rake = 0.8.7 The bundle currently has rake locked at 0.9.2. Try running `bundle update rake` If I do

Daemoninsing a rake task

非 Y 不嫁゛ 提交于 2019-12-18 04:17:12
问题 I have a rake task which runs mailman under the rails environment. I'd like to ensure that rake task is always running via a daemon. My rake task is rake incoming_mail How would I go about daemonising that? 回答1: If you are on linux you could consider using start-stop-daemon. start-stop-daemon -S --pidfile /var/run/incoming_mail.pid -u rails_user -d /path/to/your/rails/app -b -a "rake incoming_mail" To later gracefully kill the process you can use most of the arguments but replace -S with -K.

Use older version of Rake

三世轮回 提交于 2019-12-18 03:34:07
问题 I have Rake version 0.9.1 but I need to use 0.8.7 for a project, and I'm fairly certain I have both version installed but it always uses 0.9.1 by default. Is there a way to specify which version of Rake to use? I'm trying to run this: rake db:drop db:create db:migrate db:seed and I get this error: You have already activated rake 0.9.1, but your Gemfile requires rake 0.8.7. Consider using bundle exec. 回答1: You can specify the version of Rake to use, in your Gemfile: gem 'rake', '0.8.7' Though

How to prevent Rake test to call task db:test:prepare

不羁岁月 提交于 2019-12-18 02:44:26
问题 Every time I want to run Rake test the task db:test:prepare is being called and it rebuilds my test environment database from schema.rb and migrations. What I would like to achive is to disable the call of db:test:prepare when I want to test make Rails application. Is it possible without modifying Rails gem? 回答1: Here's a solution I've seen around: In your Rakefile: Rake::TaskManager.class_eval do def remove_task(task_name) @tasks.delete(task_name.to_s) end end In lib/tasks/db/test.rake :

How can I migrate my database with rails to the first revision without dropping the database first?

百般思念 提交于 2019-12-17 23:18:49
问题 I have a database set up for my Rails installation and some migrations set up. I would like to be able to reset my database back down to having no tables/constraints/etc., but can't find a reasonable way to do this without knowing the number of migrations or the timestamp of the first migration. Here are my options as I see them: rake db:migrate:reset rake db:migrate:down VERSION=20090701154839 where 20090701154839 is the timestamp associated with the first migration rake db:rollback STEP=15

Ruby on Rails: debugging rake tasks

…衆ロ難τιáo~ 提交于 2019-12-17 23:06:17
问题 When I write debugger it does not start: NoMethodError: undefined method `run_init_script' for Debugger:Module from /usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby-debug-base.rb:239:in `debugger' from (irb):4 If I run rake my:task --debugger ,it returns me to console immediately. How is it possible to debug rake tasks? 回答1: Andrey Kouznetsov's answer didn't work for me using Ruby 1.9.3. The ruby-debug gem doesn't seem to support Ruby 1.9. I had to use the debugger gem: https