rake

Rake and Uninitialized Constants

你。 提交于 2020-01-02 18:24:10
问题 I have spent hours upon days trying to resolve this. Rake is throwing the following error: dcarpenter$ rake rake aborted! uninitialized constant ActionView::Helpers::JavaScriptProxy I can't seem to find anyone who has had this issue on Google, this site or elsewhere. What steps should I take to resolve this and what do I need to know? rake --trace yields: /Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing' /Users/dcarpenter/Dropbox/workspace/gems

How to run a full MiniTest suite without Rake?

∥☆過路亽.° 提交于 2020-01-02 02:21:06
问题 Looked at this question already, and that more or less mirrors how I currently run my whole suite. Additionally, I've setup the following rake task: Rake::TestTask.new do |t| t.name = "spec:models" t.libs << "test" t.pattern = "spec/models/*_spec.rb" end But I notice when I run this using time rake spec:models , that it completes in about 2.36 seconds. If I run all the individual tests in that directory using ruby /path/to/spec.rb (all are isolated from ActiveRecord currently--no persistance

require lib in rake task

南楼画角 提交于 2020-01-01 10:47:10
问题 I have a file alert_import in lib/models/alert_import', I would like to use in my task sth like this: task :send_automate_alerts => :environment do # STDERR.puts "Path is #{$:}" Rake.application.rake_require '../../lib/models/alert_import' ai = AlertImport::Alert.new(2) ai.send_email_with_notifcations end In this code I get error: Can't find ../../lib/models/alert_import in AlertImport I have: module AlertImport class Alert def initialize(number_days) @number_days = number_days end def get

newbie: error message when 'rake -T'

為{幸葍}努か 提交于 2020-01-01 09:10:11
问题 I am using Ruby Enterprise Edition for my project. When I check all my rake task by run the command rake -T , I got the following error message: You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this. The error message implies that I can use bundle exec to solve the problem, but I am not sure how? So, how to get rid of this error message? ------------------------------ more --------------------------- I prefer to update my Gemfile

404 error with open-uri in a rake task… what's causing it?

北战南征 提交于 2020-01-01 08:04:09
问题 I have a rake task that fetches JSON data from an API, parses it, and saves it to the database: task :embedly => :environment do require 'json' require 'uri' require 'open-uri' Video.all.each do |video| json_stream = open("http://api.embed.ly/1/oembed?key=08b652e6b3ea11e0ae3f4040d3dc5c07&url=#{video.video_url}&maxwidth=525") ruby_hash = JSON.parse(json_stream.read) thumbnail_url = ruby_hash['thumbnail_url'] embed_code = ruby_hash['html'] video.update_attributes(:thumbnail_url => thumbnail_url

404 error with open-uri in a rake task… what's causing it?

情到浓时终转凉″ 提交于 2020-01-01 08:04:09
问题 I have a rake task that fetches JSON data from an API, parses it, and saves it to the database: task :embedly => :environment do require 'json' require 'uri' require 'open-uri' Video.all.each do |video| json_stream = open("http://api.embed.ly/1/oembed?key=08b652e6b3ea11e0ae3f4040d3dc5c07&url=#{video.video_url}&maxwidth=525") ruby_hash = JSON.parse(json_stream.read) thumbnail_url = ruby_hash['thumbnail_url'] embed_code = ruby_hash['html'] video.update_attributes(:thumbnail_url => thumbnail_url

Rails Devise User Exists on empty DB

女生的网名这么多〃 提交于 2020-01-01 06:26:27
问题 I am trying to create a User through Devise but am running into issues. home#land def land @resource = User.new @devise_mapping = Devise.mappings[:user] end land.html.haml = form_for @resource, :as => :user, :url => registration_path(:user), :remote => true do = label_tag 'user[email]', raw("<h3>Stay Informed!</h3>") = text_field_tag 'user[email]', nil, {:placeholder => "Your email", :required => true} %input(type="submit" name="commit" value="Add") user.rb class User < ActiveRecord::Base

can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2 in Rails 3.1

佐手、 提交于 2020-01-01 04:46:11
问题 I'm just trying to get the most basic of basic shell of a rails app running under 3.1, and I'm getting this weird error when I run bundle exec rake db:migrate- Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2. Make sure all dependencies are added to Gemfile.) All the posts that I've read here and elsewhere say I should be using the newer mysql2 adaptor for rails 3.1, so I have- gem 'mysql2', '0.3.2'

Access Rake Task Description from within Task

女生的网名这么多〃 提交于 2020-01-01 04:26:44
问题 Within a rake task how does one query the description? Something that would give: desc "Populate DB" task populate: :environment do puts task.desc # "Populate DB" end 回答1: task must be defined as a parameter for the task-block. desc "Populate DB" task :populate do |task| puts task.comment # "Populate DB" puts task.full_comment # "Populate DB" puts task.name # "populate " end Edit: This solution works with rake 0.8.7. At least rake 0.9.2.2 need an additional Rake::TaskManager.record_task

Rails - Populate test database with development data

南楼画角 提交于 2019-12-31 08:48:45
问题 Is there any trivial way to copy the data from developmenet database into the test one? I know theres a way to copy schema and recreate database, but is there any rake task to populate test database with development one? 回答1: You can use mysql directly: mysqldump app_development | mysql app_test 回答2: You can use: rake db:test:clone To copy the development db into test. 回答3: For all databases: rake db:test:clone && rake db:seed RAILS_ENV='test' 回答4: If you just want to clone the development DB