Try this rake task: namespace :reset_database do desc "Destroy all table entries." task :all => :environment do ActiveRecord::Base.connection.tables.each do |table| if table != 'schema_migrations' table.singularize.camelize.constantize.destroy_all end # Use this if you want to use the normal seeds: # Rails.application.load_seed # Use this if you want to run another rake task:...
You don't need to "intercept" all requests and check for a specific path. You simply want mount_proc, to handle a specific route with a proc. Add the following before server.start: server.mount_proc '/health_check' do |req, res| res.body = 'what what' # your content here end You'll probably want to wrap this...
ruby,testing,rake,minitest,rake-task
You solve this issue by using Rake::Task["task_name"].clear like this: task :test_task do Rake::TestTask.new do |t| puts 'within test task' t.libs.push 'specs' t.pattern = 'specs/*_spec.rb' ENV['STACK'] = 'stack1' puts "test stack #{ENV['STACK']}" end end task :unit_task do Rake::TestTask.new('unit') do |t| puts 'within unit task' t.libs.push 'specs' t.pattern = 'specs/*_unit.rb' ENV['STACK'] =...
ruby-on-rails,ruby,rake,foreman
Can be achieved with Foreman by running in the same process as daemonized task (e.g. with rails server). If one-off taks is rake lego:update_all Then corresponding Procfile is web: rake lego:update_all && rails s sidekiq: bundle exec sidekiq ...
ruby-on-rails,migration,rake,version
rake db:migrate:status will show all the migrations, along with whether they have been applied or not. `...
ruby-on-rails,ruby,mongodb,rake,rake-task
I finally found the solution myself. The key are the mongoid sessions you can define inside mongoid.yml. If you want to copy production data to sandbox, you can define a second session inside your sandbox environment (you start the task in sandbox env, and it gives you access to the...
ruby-on-rails,database,postgresql,rake
You've got a reasonable start there. Within that commented space, though, here's what you'll need to do: Based on the data in the other CSV columns, find the correct Home instance in your DB. (Something like Home.where(col1: row['col1']) but using enough columns to get a proper match.) Update that instance...
ruby,json,ruby-on-rails-4,sqlite3,rake
When you loop though the JSON, you will be looping through each key and value within the JSON. This is not what you want. You want to create one character from the data. It would look something like this: char_data = JSON.parse(File.read("#{Rails.root}/app/assets/seed/netfive.json")) Character.create char_data You will have to be careful...
ruby,rake,web-deployment,file-permissions
Rake isn't really your problem here. Rake doesn't know anything about uploading files or setting permissions; it just runs the commands as defined in the task. The actual file upload is happening via rsync. According to the rsync man page, you should be able to use the option -p (AKA...
ruby-on-rails,ruby,terminal,syntax-error,rake
You have a typo on line 16th: Location.create(area: 'College Ave', should be Location.create(area: 'College Ave') ...
ruby-on-rails,ruby,ruby-on-rails-4,rake,bundler
You are trying to run "rake db:create:all" which would create your database but as error states - it seems you don't have your config/database.yml file. It's a configuration file that tells rails how to connect to your database. You can read more about it here. If you really want to...
ruby-on-rails,ruby,gem,rake,bundler
It seems that you need to re-install ruby..Hopefully that might solve the problem.Had faced this issue previously.Resolved by reinstalling ruby.
Your shell is probably interpreting the argument to Rake as something special, so quote it to avoid that from happening: rake 'my_task[1,2]' ...
ruby-on-rails,ruby,rake,minitest
You're using the guard-minitest gem, please see the first line of the Install section of its README Namely: Please be sure to have Guard installed before you continue. ...
ruby-on-rails,ruby,rake,rake-task
The problem is the line Rails.application.config.method. The standard method Kernel#method is used to retrieve a method object and (kind of) a reserved word since it is defined on all objects. To fix this, you must name your custom config differently, for example Rails.application.config.cat_method.
Figured it out. The following rake code works: rule '.o' => ->(t){t.pathmap("src/%f").ext(".c")} do |task| sh "gcc -c #{task.source} -o #{task.name}" end ...
In order to use the -%> syntax in ERB you need to set the trim mode option to '-'. This is the third option to the constructor, you will need to pass nil as the second (unless you want to change the safe_level from the default): ERB.new(" <% if var...
You can use mkdir_p in FileUtils task :create_directories do FileUtils.mkdir_p 'build/subfolder' end documentation HTH...
ruby-on-rails,ruby-on-rails-4,gem,rake,bundler
TL; DR: gem install rake -v '10.4.2' So, I had this problem myself. I wanted to know why rails s would work yesterday and not today. First I checked if I was in the correct directory, I was. Then I re-ran bundle install to make sure rake was getting installed....
Drop the ~ to be: /Applications/My\ App/Folder1/Folder2 ~ specifies the users home directory, which is not where applications are normally stored....
ruby-on-rails,ruby,rake,bundler,eventmachine
From what I have seen it seems there is an issue with this version, the only way I found to solve this issue was this thread. My suggestion is look in the Gemfile.lock and see which gem requires that version and think about if you actually need it or check...
Shame on me. I didn't define ruby local version for the project. When using RVM: $ rvm install 2.1.1 $ rvm use 2.1.1 For Rbenv: $ rbenv install 2.1.1 $ rbenv local 2.1.1 ...
ruby-on-rails,ruby,shell,rake,rvm
if you are running another ruby project, make sure you clean the current bundler environment before run command. Bundler provides an easy way to tackle this inconvenient by doing: Bundler.with_clean_env{ render json: `cd /Users/user/project && rvm use [email protected] && BUNDLE_GEMFILE=path/to/Gemfile bundle exec rake users:build` } take note of BUNDLE_GEMFILE and...
ruby,path,environment-variables,rake
When using sh from within a Rake task, it spawns a shell and executes the command. The lifetime of environment variables, PATH being one of them, is until the shell exits. So the :make_path task spawns a shell that exports this variable and then exits. Next time a shell is...
ruby,heroku,github,rake,travis-ci
This issue was solved by passing the url to the Redis initialization constructor explicitly instead of using the 'old' way of passing the parsed symbols. The old way seems to work best (if not exclusively) with versions before Rails 4. This was confirmed by the Redis To Go documentation on...
[:some_random_name2] is referring to arguments that you can pass into your rake task. May I suggest checking out this article which can explain in more depth passing arguments to a rake task. When you call rake -T from the command line, you should see: rake example: some_random_name1[some_random_name2] (assuming your namespace...
ruby,rake,sublimetext,sublimetext3
Rubymine is the best tool I've tried: https://www.jetbrains.com/ruby/ ...Unless you are a student or a successful open source developer, the product is not free. I tried SublimeCodeIntel, but it was not powerful enough for my needs....
ruby-on-rails,ruby,rspec,rake,rakefile
Thanks to @MaxWilliams for the link to this post How do I debug a slow rails app boot time? I started using Mark Ellul's Bumbler - http://github.com/mark-ellul/Bumbler It gave me exactly what I wanted - an insight into what's going in the background and which gems are taking the time....
ruby-on-rails,ruby,rake,rake-task,rakefile
You pass arguments to a task by enclosing them in [] directly after the task name. e.g. rake create_api_key[xaaron_test] If you use zsh, you need to escape the opening [ e.g. rake create_api_key\[xaaron_test] ...
According to the documentation sqlite it is not supported you will need to copy the data to new column of bigint type and change its name
If memory serves, that is the syntax used to call rake feature and deliver two arguments to the feature task, namely 'foo.feature' and 100000. You'll want to look into your rakefile and see what is expected for the task in question. For what it's worth, it's an unwieldily and error-prone...
Use require 'shellwords' and Shellwords.escape You can find more info on these in "shellescape" and "Shellwords"
ruby-on-rails,ruby,heroku,rake
After some hours trying different solutions, this is the only thing that worked for me: rake rails:update:bin And push the changes again to Heroku....
Assuming you have not created any tasks file in lib/tasks, you won't have any task named install. rake -T will list all of your available tasks (look for a line starting with "rake install"). btw, what are you trying to achieve?...
ruby-on-rails,ruby,database,heroku,rake
Working with Heroku support, I was not able to get this to work with the current configuration. So in the end I decided to create a database for our staging app. Imported the latest dump file from production. And ran heroku run rake db:migrate against staging. I still got the...
ruby-on-rails,ruby,migration,rake
Solution is quite simple actually. When running rake db:migrate, migration tool expects models to exist. Therefore, here, we get a uninitialized constant error. Migration tool is searching a State model and will use it to call create method. Then, there are several ways to fix this issue. Most simple is...
ruby-on-rails,postgresql,ruby-on-rails-4,rake
In case of postgresql you will not find any file like development.sqlite3. It's in case of sqlite only. You did not provided database credential in your database.yml file might causing this error. Try pass username and password as well. development: adapter: postgresql database: dimension_development pool: 5 timeout: 5000 username: xxxx...
You should definitively use migrations. If you create a rake task and then delete it, the changes will only be applied to this instance of your database (which can be a development database). When you deploy your application to production, or even run your specs, you would have to manually...
ruby-on-rails,rake,rake-task,rakefile
You have a typo: enviroment instead of environment That's why you are getting this error: rake aborted! Don't know how to build task 'enviroment' ...
ruby-on-rails,ruby,rake,rakefile
puts sends the text to STDOUT, which is different when you run rake from the terminal versus invoking from another ruby process. Where do you expect to see this text?...
ruby-on-rails,ruby,json,rake,bundler
I had the same error too. Googled around and found these two posts http://community.onemonth.com/t/install-rvm-error/1883/25 https://bugs.ruby-lang.org/issues/9444 The first post's solution fixed it for me, so for you it would be: rvm get stable rvm reinstall ruby-2.1.5 ...
ruby,multithreading,rake,rakefile
Yes, rake allows the jobs to run in parallel. To set up the level of parallelism, use -j switch. From rake --help: -j, --jobs [NUMBER] Specifies the maximum number of tasks to execute in parallel. (default is number of CPU cores + 4) But, the job itself must be written...
If you have rspec-rails in your Gemfile, then when the gem is loaded by Rails is will execute this line: https://github.com/rspec/rspec-rails/blob/v3.2.1/lib/rspec-rails.rb#L19 load "rspec/rails/tasks/rspec.rake" which in turn defines the default rake task: https://github.com/rspec/rspec-rails/blob/v3.2.1/lib/rspec/rails/tasks/rspec.rake#L6 task :default => :spec That's why the default rake task runs the specs in your Rails app. Furthermore,...
ruby-on-rails,ruby,rake,dbmigrate
You've already created that particular table. Try this from your terminal: rake db:drop db:create db:migrate Or: rake db:reset db:migrate So basically, you will start your database from scratch, which will avoid the current error. Note that for new migrations, you only run the 'rake db:migrate' command otherwise your existing data...
ruby-on-rails,ruby,ruby-on-rails-3,migration,rake
looks like you have an ActiveRecord::RecordNotFound error in ProductsController#index, so method record_not_found called with params[:id] = nil, which in turn causes an TypeError at this line: flash[:alert] = "Cannot find record number " + nil + ". Displaying all records." anyway for a more exact answer need to look at...
Cucumber::Rake::Task.new(:all_tag_1) do |t| tags = '--tags [email protected] --tags @tag1' t.cucumber_opts = "features/scenarios/folder_1 --format html --out features/build_results/all_tag_1.html --format pretty #{tags} --format junit --out features/build_results/reports" end This command will only run scenarios from features/scenarios/folder_1 folder... ...
You are trying to update the provider and uid columns to not allow null values, and you have written your migration correctly. This error is arising because one or more of them (at least provider) already contains records with null values. You'll have to either drop the records with null...
ruby-on-rails,ruby-on-rails-4,activerecord,rake
Try this Entry.where(approve_disapprove: '3') and why 3 is string you can use like this too Entry.where(approve_disapprove: 3) You can loop through all the pending entries and send email to them def self.check_pending check_pending = Entry.find_all_by_approve_disapprove(3) check_pending.each do |entry| EntryMailer.check_pending(entry).deliver end end Then in your EntryMailer def check_pending(entry) @entry = entry...
ruby,multithreading,rake,rake-task
The reason this happens is because you are not calling join after the Thread block. However, when you use .value, it will automatically join the thread for you (as documented here) Try this: task :test_me do t1 = Thread.new do puts 'start' uri = URI.parse("http://google.com/") response = Net::HTTP.get_response(uri) puts response.inspect...
ruby,ruby-on-rails-3.1,rake,bundler
Without you showing the error message you are getting, I'm assuming it has less to do with Bundler than it does Rake. When the rake command is run, it searches for a Rakefile starting in the current directory and traversing up the tree until it finds one. You can override...
I had this problem using rbenv for my ruby 2.2.0 install. Fixed through trial and error. I tried doing gem install rake but this didn't fix it. So I did: gem uninstall rake rbenv global 2.1.1 rbenv rehash rbenv uninstall rake #this time gives error "rake is a default gem"...
Changing the gemfile solved this. Before: #gem 'therubyracer', platforms: :ruby gem 'libv8', '3.11.8.3' gem 'therubyracer', '0.11.0beta5' Instead, I wrote: gem 'therubyracer', platforms: :ruby #gem 'libv8', '3.11.8.3' #gem 'therubyracer', '0.11.0beta5' It was related to a Javascript runtime, but rake error was way too cryptic....
ruby-on-rails,ruby,testing,rake
Since 2.0 minitest-rails does not add minitest rake tasks. The default rails test rake tasks are used. See the section on running tests in the README. Also, if you are including the minitest-rails Railtie in your config/application.rb, then you shouldn't place the dependency in the :test group in your Gemfile....
I debug the app and found out: 1) Your specs depend on order. For example bin/rspec spec --seed 49796 # gives 5 failures bin/rspec spec --seed 1 # gives 0 failure 2) Also I place caller to User and I can see that model User is loaded twice (you should...
ruby-on-rails,ruby,rake,rails-activerecord
The reason I was getting this weird cryptic SQL'ish output is because I had Heroku's rails_12factor gem in my gemfile and not grouped to :production. The solution was to do: group :production do gem 'rails_12factor' end and run bundle...
ruby-on-rails,ruby,rake,rake-task
This is not specific to Rake, it is just a consequence of lexical scope and the way Ruby handles local variables, declaring them on first use. First you assign a value to path: path = "/home/tomcat/tomcat" Then you create the stage namespace and reassign the variable: path = "/home/tomcat/stage-tomcat" Note...
You are running the spec with ruby, not rspec. This is why you don't see any output, your test will run as if it is a regular ruby script. Change your Rakefile to run rspec instead: begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task :default => :spec rescue LoadError puts "RSpec is not...
ruby-on-rails-4,rake,travis-ci
It turns out the problem was related to the username for the test database in my database.yml file. I opted to not set the username for the test database after looking at this SO question. The build is finally passing. Hopefully this helps someone in the future.
ruby-on-rails,rake,models,migrate
There is a typo here: it is db:migrate (instead of bd:migrate). Also, rake does not create models. To create models along with migrations, use rails generate model MyModel. On the other hand, if all your tables are created using migrations, then just create the model files manually in the app/models...
ruby-on-rails,model,environment-variables,rake
I restarted the server and everything worked fine. Mysterious...
ruby-on-rails,ruby,ruby-on-rails-3,rake
Stop spring by using command bin/spring stop and then run rake command again. It would fix this issue....
windows,rake,bundler,berkshelf,albacore
I figured out the problem as I wrote the question and stumbled upon new ideas. The root problem was that the Ruby binary and gems installed with the ChefDK were conflicting with the system install of Ruby. Specifically, the rake task was executed under the system Ruby installation, but when...
You are defining method inside rake task which is the issue here. Define it outside your task. task :update_state_for_search_request => :environment do t_last = MyModule.where("condition").last.id t_first = 0 until t_first >= t_last do t_first=print_id(t_first) end end def perform(sid) # action my_data = MyModule.where("name='abcd' and id > #{sid}").limit(1000) # action return...
def self.scan in order to make the method a class one, not instance method(called on instances of a class). Or simply use Lexicon.new(args).scan
The correct answer based off the comment to the question is to run: rake app:rails:update:bin at the root of the engine....
Note that Kernel is a module which is included into every ruby Object. And Kernel#system is an instance method (not a class method). One solution (although discouraged by rspec maintainers) is to use "Any instance": it "runs 'bundle exec rspec spec'" do expect_any_instance_of(Kernel).to receive(:system).with "bundle exec rspec spec" Rake::Task[:test].invoke end...
ruby-on-rails,hash,rake,rakefile
symbolize_keys! method from ActiveSupport lib and you can't use this method without this lib. You can write own method for convert keys. I found one example here...
ruby-on-rails,ruby,activerecord,rake
user1 = User.new user1.email = "[email protected]" user1.name = "testname" user1.password = "password" user1.save! First of all you need to save user for it's id. Then .... user1.library = Library.new library1 = user1.library.save! book = Book.create!(hash_of_attributes) book1 = library1.books << book puts "book1 library_id " + book1.library_id.to_s ...
Well, it is not coming as you didn't use any descriptions. Add a description using desc like below : $ cat Rakefile namespace :access_token do desc "some tasks" task :refresh do end end $ rake -T rake access_token:refresh # some tasks Now, if I remove the desc, it wouldn't come....
ruby-on-rails,rake,refinerycms
The reason you get this error is because meta_keywords used to exist, but now it doesn't. Make sure you are using an up to date version of the seo_meta library.
mysql,ruby-on-rails-4,rake,bundler,dbmigrate
Answer as discussed: - Execute (bundle exec rake) db:create, db:reset This will create the DB using your seeds and schema as they are on the other machine. Not knowing the specific error details I can't comment on why you received the error in the first place (unless it's saying you...
ruby,ruby-on-rails-4,testing,rake,bundler
It appears that you use the Metal test runner. I cannot see anywhere on its documentation supporting path testing such as test/models. Its main feature is to run tests by line number. If you would like to execute all of your model tests you could use Rails' rake test:models to...
ruby-on-rails,ruby,postgresql,rake
Seed file is usually used only to populate the database from a blank state for the first time. The seed file - unless it is deleting entire tables and recreating them - can be ignored after the first run. Removing OLD status has to be done in the database; not...
ruby-on-rails,ruby,sqlite,rake,rake-task
Just create a Cron task that runs periodically. That Cron task starts a shell stript that just does all the step you would run manually. There is a gem (https://github.com/biola/turnout) at helps with the maintainance page. It provides rake tasks like rake maintenance:start and rake maintenance:end. I think it...
Rake is just ruby code, so unless you are not using some other gem that somehow manipulates your simple rake command. you should NOT be loading gemsec file! I searched the rake repository on github for this $global variable and found nothing. here Please update the question if you think...
ruby-on-rails,ruby,rake,rufus-scheduler
As @jmettraux (the creator of rufus-scheduler!) has already answered, the problem is that the rake task is defined in a .rb file instead of .rake file. Adding some more details to help in the future. While creating a new rake task, you could get the rails generator to automatically create...
You want to use the asmver task or asmver_files for multiple projects. https://github.com/Albacore/albacore/wiki/asmver-and-asmver_files...
ruby-on-rails,ruby,rake,instagram-api
Chad Pytel and Tammer Saleh call this "Fire and forget" antipattern in their Rails Antipatterns book: Assuming that the request always succeeds or simply not caring if it fails may be valid in rare circumstances, but in most cases it's unsufficient. On the other hand, rescuing all the exceptions would...
For non-interactive login, you need to use an API key, which Heroku will read from the HEROKU_API_KEY environment variable. You can fetch the key for your account from a logged-in CLI using heroku auth:token. There's no way to avoid authentication just because you're running inside Heroku already. That would have...
ruby-on-rails,ruby,rake,rake-task
Agree with these other comments. This is a straightforward error. If you load up your rails console (rails c) in the environment in question (development or production or whatever) and type ExchangeRate.new then you should see the same error. From there investigate the connection to the DB and make sure...
I would find the current state of the Schema by opening up the schema.rb file (located in db/schema.rb), the first line looks something like: ActiveRecord::Schema.define(version: 20150507210038) do Match up that version number with the migrations in your db/migrate folder. Perhaps you are already at the appropriate migration. To go back...
I get the same error in irb, and it makes sense to me. ENV is for getting and setting environment variables, which have string values. So you can't store something that's not a string in it. I'm not sure why you're trying to do that anyway? Are you trying to...
ruby-on-rails,ruby-on-rails-4,rake,rake-task
This has already been answered on Stack Overflow here: http://stackoverflow.com/a/8847126/4461194 1.9.3-p551 :001 > ActiveRecord::Migrator.current_version (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" => 20150114073202 ...
ruby-on-rails,ruby,rake,rake-task
You can use the method OptionParser#order! which returns ARGV without the wrong arguments: options = {} o = OptionParser.new o.banner = "Usage: rake user:create [options]" o.on("-u NAME", "--user NAME") { |username| options[:user] = username } args = o.order!(ARGV) {} o.parse!(args) puts "user: #{options[:user]}" You can pass args like that: $...
For applying the new changes in the migration file, you need to run rake db:migrate. If the migration has already been run before you made the change, then run rake db:rollback to roll back the migration and apply it again. rake db:reset does not apply new changes in migration files....
ruby-on-rails,ruby,design-patterns,rake
In my opinion all API-related classes should be separated and lie in app/services/ directory, moreover, I'd create adapters for each of these classes(for example if external API will change version case - I wrote a post about this approach if you are interested). Next, if your logic hits multiple models,...
ruby-on-rails,ruby,rake,actionmailer
For now I have switched from using a Sneakers worker that is constantly taking messages from the queue, to a scheduled rake task that takes all available messages in the queue. I don't know why the Action Mailer performs so differently in the Sneakers worker versus the Rake Task, but...
In your demo file, both variables person and c are local variables and will not be accessible from outside of that context. If you require demo.rb into an irb session, the behavior should be the same; neither c nor person will be defined. A good way of dealing with this...
You have a problem in line 20: Rake::Task[myapp:runTests].invoke('--client=EXAMPLE', '--env=Staging', '--app=myappalt') The myapp:runTests is no symbol and no string. If you make it a string, then your task will run: Rake::Task['myapp:runTests'].invoke('--client=EXAMPLE', '--env=Staging', '--app=myappalt') With Rake::Task[...].invoke you don't work inside you namespace, you call a task on a global level....
Found the answer for this in Wiki for apartment gem. Rake::Task["db:test:purge"].enhance do ActiveRecord::Base.connection.execute('CREATE SCHEMA IF NOT EXISTS shared_extensions;') ActiveRecord::Base.connection.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;') end ...