rake

Load only part of environment for rake task?

放肆的年华 提交于 2019-12-11 11:29:31
问题 I've seen a bunch of articles relating to loading the entire Rails environment for a task. However, I'm concerned that this is unnecessary because I only use two models for my task (plus the 'resque' and 'resque/scheduler'). How can I only load certain parts of an environment for my task? Also, this question seems to be the same, but it's gotten old and no one seems to have sufficiently answered it... I'll ask now, ahead of time, that someone please give code rather than just an explanation.

Render a view from a rake task

此生再无相见时 提交于 2019-12-11 11:20:14
问题 I'm trying to send mail from a rake task. I've already manage to send email but the problem is the file I send. I want to send a view which will be modify each time that the mail will be send. I've install the gem render_anywhere to render a view from my rake task but I keep having this error : NoMethodError: undefined method `formats' for String:0x007ff1a1068b88> here is the part of my rake task that should do the job : require 'render_anywhere' include RenderAnywhere require Rails.root.join

Rake is out of synch with my Database

元气小坏坏 提交于 2019-12-11 10:57:46
问题 I have inherited a Ruby on Rails project where the programmer didn't use rake to create the db schema, so it seems very out of synch, is there a way to rectify this? 回答1: First create a schema.rb file rake db:schema:dump Then make a migration ot of it. class CreateMigration < ActiveRecord::Migration def self.up # insert schema.rb here end def self.down end end You might also need to create the schema_migrations table, and manually add the timestamp for this migration to it. 来源: https:/

Why isn't task scheduler working but running rake manually working

二次信任 提交于 2019-12-11 09:36:34
问题 I have an app running on heroku and once an hour I need to run a rake task called get_instagram_photos. I am scraping instagram and then adding the info to the database. If I run the following manually in terminal the task works great. $> heroku run rake get_instagram_photos I am using the new scheduler addon that heroku implemented. I added get_instagram_photos as one of the tasks that I would like to run once an hour. The dashboard seems to tell me that it runs once an hour however I don't

Rake is too verbose, echos test command

喜夏-厌秋 提交于 2019-12-11 08:17:24
问题 Rake is too verbose: $ bundle exec rake test:units /Users/jared/.rvm/rubies/ruby-1.8.7-p370/bin/ruby -I"lib:test" -I"/Users/jared/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib" "/Users/jared/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" Loaded suite /Users/jared/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/rake_test_loader Started ..................................... This is what I want: $ bundle exec rake

Neither migrations nor loading schema adds a column to Rails/MySQL database

﹥>﹥吖頭↗ 提交于 2019-12-11 07:32:22
问题 I've created a migration to add an is_ms_admin column to my MySQL database in Rails: class AddIsAdminToUsers < ActiveRecord::Migration def change add_column :users, :is_ms_admin, :boolean end end This has correspondingly updated the schema: create_table "users", force: :cascade do |t| t.string "email", limit: 255, default: "", null: false t.string "encrypted_password", limit: 255, default: "", null: false t.datetime "remember_created_at" t.integer "sign_in_count", limit: 4, default: 0, null:

rake aborted! Operation not permitted - Carrierwave Delete tmp files that failed validation

社会主义新天地 提交于 2019-12-11 07:22:27
问题 I am using Carrierwave, s3 and fog to upload videos. I added in a file_size_validator file so that videos can't be larger than 5mb. My understanding of how Carrierwave works (please advise if incorrect). Carrierwave saves a copy of the file to the tmp file folder and then performs validations on it so if it passes, the file is uploaded to S3 and the code below removes the tmp file from the local filesystem: video_uploader.rb before :store, :remember_cache_id after :store, :delete_tmp_dir def

run and stop rake task from ruby file

邮差的信 提交于 2019-12-11 07:17:48
问题 I already know that running a rake task from .rb file can be done by running: system "/usr/bin/rake #{task} #{args.join(' ')} > #{Rails.root}/log/rake.log" But how to stop a currently running rake task from ruby file? Thanks! 回答1: Perhaps you could do a ps_aux = system "ps aux | grep #rake_task_name" then, parse the pid. then, issue a kill command system "kill #pid" I haven't tried this yet though. 回答2: From within the script, you could run the commands suggested by pat (parsing for the pid)

Compiling selenium webdriver source - buck issues

社会主义新天地 提交于 2019-12-11 06:47:34
问题 Been spending yesterday compiling the open source Appium tool, and today Selenium. Between the projects, on Windows, I've had to install different versions of the JDK, ruby, python 2.7 (I had 3.6), git, ffmpeg, opencv4nodejs,nodejs, npm, choco and a variety of other random tools and utilities. cmake. Bundletool. Ant. Anyway, I've gotten further than I've gotten before, but now for the last few hours I'm stuck. go.bat clean executes fine go.bat <anything else> seems to fail, whether its used

Rake assets:precompile cannot find ruby

邮差的信 提交于 2019-12-11 05:06:02
问题 I'm setting up a Ruby on Rails production environment. I'm using a multi user install of RVM. When running rake assets:precompile I get the following error. Other rake tasks seem to work fine. ruby@myserver:/sites/rails/necura_staging/shared/cached-copy$ bundle exec rake assets:precompile --trace ** Invoke assets:precompile (first_time) ** Execute assets:precompile /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby ruby /usr/local/rvm/gems/ruby-1.9.3-p448@global/bin/rake assets:precompile --trace