Tag: rake

如何debuggingRails资源预编译,这是不可耐受的缓慢

我正在开发一个Rails 3.2项目,尽pipe我不认为这个项目很大,但是资产在最近几个月里增加了一些。 资产包括JS(无咖啡剧本)和SASS文件; 我们有不less的图片,但是从早期开始,它们就更less了,所以我不认为它们是一个很重要的因素。 我们可能有大约十几个库,大部分都是小的,最大的是Jquery UI JS。 部署是通过Capistrano完成的,而且开始显而易见,部署到分期的速度明显快于生产。 为了说明,同时避免了有关不同服务器和networking效应的因素,我只需在笔记本电脑上依次运行以下三个命令,如下所示: $ time RAILS_ENV=production bundle exec rake assets:precompile ^Crake aborted! [Note I aborted this run as I felt it was getting stupidly long…] real 52m33.656s user 50m48.993s sys 1m42.165s $ time RAILS_ENV=staging bundle exec rake assets:precompile real 0m41.685s user 0m38.808s sys 0m2.803s $ time RAILS_ENV=development bundle exec […]

NoMethodError:调用Gem :: Package:Class的私有方法`open'安装rake(10.0.3)时发生错误,Bundler无法继续

我正在尝试从github同步的rails项目上工作。 即使rake-10.0.3安装成功,“bundle install”也会失败。 我是新来的铁轨,不知道如何继续这个。我GOOGLE了错误,并试图安装不同版本的耙子的解决schemebuild议,但没有帮助。 这是我正在做的…请帮助。 ruby 1.9.3p374 (2013-01-15) [i386-mingw32] >rails s ←[31mCould not find kaminari-0.14.1 in any of the sources←[0m ←[33mRun `bundle install` to install missing gems.←[0m >bundle install Fetching gem metadata from https://rubygems.org/……….. Fetching gem metadata from https://rubygems.org/.. NoMethodError: private method `open' called for Gem::Package:Class An error occurred while installing rake (10.0.3), and Bundler […]

Ruby on Rails:debuggingrake任务

当我编写debugger它不会启动: 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 如果我运行rake my:task –debugger ,它会立即返回到控制台。 如何debuggingrake任务?

当我运行rake:db migrate命令时,出现“Uninitialized constant CreateArticles”

我创build了一个模型ruby脚本/生成模型文章(简单的enuff) 这里是迁移文件create_articles.rb: def self.up create_table :articles do |t| t.column :user_id, :integer t.column :title, :string t.column :synopsis, :text, :limit => 1000 t.column :body, :text, :limit => 20000 t.column :published, :boolean, :default => false t.column :created_at, :datetime t.column :updated_at, :datetime t.column :published_at, :datetime t.column :category_id, :integer end def self.down drop_table :articles end end 当我运行rake:db migrate命令时,我收到一个错误耙子中止! “未初始化的常量CreateArticles”。 有谁知道为什么这个错误不断发生?

从已经在数据库中的数据创build种子文件

我正在使用Rails 3.0.3,并为我的“类别”表中的数据已经在数据库中,但要从中创build一个种子文件。 是否有任何耙子任务会从这张表中为我生成seeds.rb格式?

Model.reset_column_information不会在rails迁移中重新加载列

我正在使用Rails 3.2并进行包含代码的迁移: add_column :users, :gift_aid, :integer, :default => 2 # reset columns User.reset_column_information … code here to load legacy data from sqlite3 database … # now create a user with the loaded column data user = User.create( …other cols…, :gift_aid => migrated_gift_aid_column_data, …other cols… ) 运行迁移时会得到unknown attribute: gift_aid 。 User.column_names在调用User.column_names之前和之后显示相同的列表。 奇怪的是,当我手动删除列在MySQL中,并重新运行迁移它按预期工作。 从第一次迁移开始,再次使用一个空的数据库,它不起作用,所以这是运行所有的迁移,而不是单一的迁移。 我有几个以前的用户模型的迁移,都包括reset_column_information和工作正常。 我真的在摸索这个问题 – […]

如何在Ruby脚本中运行Rake任务?

我有Rake任务,我通常会从命令行调用一个Rakefile : rake blog:post Title 我想写一个Ruby脚本多次调用Rake任务,但是我看到的唯一解决scheme是使用“(反引号)或system脱壳。 什么是正确的方法来做到这一点?

在哪里定义了rake任务?

在新创build的Rails项目(由rails someName生成)上,可以运行一些“默认”rake任务,如: rake test rake db:migrate 等等 问题是,这些任务在哪里被描述? 默认的Rakefile没有所有这些任务。 此外,我检查了一些使用rspec项目,我可以运行rake spec来运行所有的testing。 spec目标在哪里定义?

我怎样才能生成自上次拉动以来发生变化的git diff?

我想脚本,最好在耙子,下面的行动到一个单一的命令: 获取我的本地git存储库的版本。 Git拉最新的代码。 从步骤#1中提取的版本Git diff到现在在我的本地资源库中。 换句话说,我想从中央库获取最新的代码,并立即生成自上次拖拉以来改变的内容。

当我在Rails中运行rake db:seed时US-ASCII(参数错误)中的无效字节序列

当我在Rails应用程序中运行rake db:seed时,出现以下错误: US-ASCII中的无效字节序列(参数错误) 我只是将science_majors添加到我的种子文件中,现在当我运行rake db:seed它给了我这个错误: 无效的字节序列错误 这是为什么,我该如何解决? 种子的一部分 @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 University', calendar: 'Semester', location: 'Pittsburgh, PA', setting: 'Large City (250-500k)', retention: '90', majors: 'business/marketing: 15%|social sciences: 14%|health professions: 11%|english: 10%|engineering: 9%|psychology: 8%|biology: 7%|history: 5%', scholarships_link: 'http://www.oafa.pitt.edu/universityschlrs.aspx', map: '<iframe width="425" height="350" frameborder="0" scrolling="no" […]