rake

rake db:migrate not working when using ActiveRecord with Sinatra

倖福魔咒の 提交于 2020-03-04 21:40:09
问题 I am trying to create a very basic Sinatra app which uses only Active Record and Sqlite3. To be as complete as possible I am following instructions from a tutorial which states the following steps in order: Create a database by putting the following code in the main app file: ActiveRecord::Base.establish_connection( :adapter =>'sqlite3', :database=>'wiki.db' ) class User < ActiveRecord::Base validates :username, presence: true, uniqueness: true validates :password, presence: true end To

如何从GitHub源安装gem?

时光怂恿深爱的人放手 提交于 2020-02-28 02:08:33
我想从最新的GitHub源安装gem。 我该怎么做呢? #1楼 尝试使用 specific_install gem,它允许您从其github存储库(如“edge”)或任意URL安装gem。 非常适用于在多台机器等上分配宝石和黑客攻击它们。 gem install specific_install gem specific_install -l <url to a github gem> 例如 gem specific_install https://github.com/githubsvnclone/rdoc.git #2楼 在新的Linux机器上,您还需要安装 git 。 Bundle在幕后使用它。 #3楼 你也可以做 gem install username-projectname -s http://gems.github.com #4楼 如果您从公共GitHub存储库获取宝石,则可以使用简写 gem 'nokogiri', github: 'tenderlove/nokogiri' #5楼 那么,这取决于有问题的项目。 某些项目的根目录中有* .gemspec文件。 在那种情况下,它会 gem build GEMNAME.gemspec gem install gemname-version.gem 其他项目有一个rake任务,称为“gem”或“build”或类似的东西

NOT able to rake db:migrate

半世苍凉 提交于 2020-01-26 04:39:11
问题 C:\Users\MEGHA>rails new sagar_blog create create README.rdoc create Rakefile ... <snip> ... Using turbolinks (2.2.1) Using uglifier (2.5.0) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. C:\Users\MEGHA>cd sagar_blog C:\Users\MEGHA\sagar_blog>rails generate scaffold post title:string \ body:text invoke active_record ... <snip> ... create app/assets/stylesheets/posts.css.scss invoke scss create app/assets/stylesheets/scaffolds.css.scss C:\Users

rake how to fix undefined local variable or method error?

♀尐吖头ヾ 提交于 2020-01-25 19:16:46
问题 i have a rake task as follows- desc 'send fetch request' task send_fetch_request: :environment do   FacebookCrawl.new.process end Yesterday this task working, but I don't know why it is not working today. I am trying to execute this with the below command- rake send_fetch_request Class details: class FacebookCrawl def initialize fb_config = YAML.load_file(Rails.root.join("config/facebook_catalog.yml")) @access_token = fb_config["facebook"]["access_token"] @product_feed_ids = fb_config[

Capistrano + RVM + Rake task

南楼画角 提交于 2020-01-25 08:29:11
问题 I have a project which uses rvm ruby 1.9.2 (set in .rvmrc in project dir). deploying with capistrano. has a rake task I want to run remotely from my local machine by capistrano. I've created a .sh file to run my task: cd /var/www/pluslook/current /home/kirill/.rvm/scripts/rvm use 1.9.2@pluslook /home/kirill/.rvm/gems/ruby-1.9.2-p180@pluslook/bin/rake parse:feed RAILS_ENV="production" --trace But when I'm trying to run this task i have an error: Using /home/kirill/.rvm/gems/ruby-1.9.2-p180

Using rake import (calling other rakefiles)

随声附和 提交于 2020-01-23 06:26:49
问题 Here's my primary rake file subrake = 'subrake' task :init => [subrake] do #call subrake.build end import subrake I see documentation on how the above steps work, but I can't figure out how to call tasks in the other subrake file. BTW, those tasks may have the same name as mine, is this an issue? 回答1: I guess I'm late with my answer, but I had the same question just few moments ago. So the solution might be useful for someone. Rakefile.rb subrake = 'subrake' task :default => :init task :init

rake about database adapter inconsistent with database.yml

拈花ヽ惹草 提交于 2020-01-23 05:54:56
问题 In database.yml (rails-generated default file): default: &default adapter: sqlite3 pool: 5 timeout: 5000 development: <<: *default database: db/development.sqlite3 test: <<: *default database: db/test.sqlite3 production: <<: *default database: db/production.sqlite3 When running rake about , I have this error: Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord)

Why does a Rake task in a loop execute only once?

守給你的承諾、 提交于 2020-01-23 04:25:08
问题 I have rails application that connects to multiple databases. I wrote custom rake task that looks like this: task :migrate_accounts_schema => [:environment] do |t| users = User.find :all, :conditions => ["state = 2"], :order => "id asc" users.each do |user| if user.state == 2 ActiveRecord::Base.establish_connection( :adapter => "postgresql", :host => user.database_host, :port => user.database_port, :username => user.subdomain, :password => "#{user.database_password}", :database => user

Activated Ruby RAKE 10.0.1, require 10.0.0

倾然丶 夕夏残阳落幕 提交于 2020-01-23 01:16:06
问题 I get this error when i try to run "rake test": avery@ubuntu:~/rails_projects/depot$ rake test rake aborted! You have already activated rake 10.0.1, but your Gemfile requires rake 10.0.0. Using bundle exec may solve this. /home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:31:in `block in setup' /home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:17:in `setup' /home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler.rb:116:in

Rails exception notifier in rake tasks

孤街醉人 提交于 2020-01-20 03:08:30
问题 I have a simple rails application with a few controller and some rake tasks. A couple of tasks are executed by cron configured with whenever gem. One of my task is executed daily and sometime it raises an exception and by default I receive this warning by cron rake aborted! undefined method `parameterize' for nil:NilClass Tasks: TOP => mailboxes:clean_processed (See full trace by running task with --trace) I want to debug what's happening and for this reason I've just installed this exception