ruby-on-rails-3.2

How to use Eclipse for Ruby on Rails (RoR)

梦想的初衷 提交于 2019-12-03 01:56:48
问题 I am new in Ruby. I have installed Ruby on Rails on Windows 7. I visited the following to choose a suitable IDE/Editor for writing Ruby code: http://rubyonrails.org/download I found the following Editors for Ruby: VIM for Rails, RadRails, RubyMine, 3rd Rail, Netbeans for Ruby I am familiar with Eclipse as I am using Eclipse for java. Can I use Eclipse for Ruby? If so, what configuration is necessary in Eclipse for Ruby project? 回答1: To save you some legwork, in Eclipse: Go to Help -> Install

How can I find a memory leak on Heroku?

青春壹個敷衍的年華 提交于 2019-12-03 01:53:05
I have a Rails 3.2.8 app running on Heroku Cedar with Ruby 1.9.3. The app runs fine when it launches but after a day or so of continuous use, I start to see R14 errors on my logs. Once the memory errors start, they never go away, even if the app is idle for several hours. Shouldnt the garbage collector clean up unused objects after a while and reduce the memory load? It seems this is not happening on Heroku. Generally, memory usage starts to creep up after running some reports with several thousand rows of data, although results are paginated. How can I find the memory leak? Plugins like bleak

Bundler could not find compatible versions for gem, updating Rails app

醉酒当歌 提交于 2019-12-03 01:50:41
After createing a brand new rails app Following the official rails blog post , attempting to convert apps to rails 3.2.0.rc2 yields the following Updated Gemfile to depend on rails ~> 3.2.0.rc2 gem 'rails', '~>3.2.0.rc2' Updated Gemfile to depend on sass-rails ~> 3.2.3 gem 'sass-rails', '~> 3.2.3' $ bundle install Fetching source index for http://rubygems.org/ Bundler could not find compatible versions for gem "activesupport": In snapshot (Gemfile.lock): activesupport (3.1.1) In Gemfile: rails (~> 3.2.0.rc2) ruby depends on activesupport (= 3.2.0.rc2) ruby Running `bundle update` will rebuild

How can i remove a column from table using rails console

好久不见. 提交于 2019-12-03 01:26:49
问题 It is easily possible to remove a column using rails migration. class SomeClass < ActiveRecord::Migration def self.up remove_column :table_name, :column_name end end I want to know if there is any way to remove a column from table using console. 回答1: You can run the codes in up method directly in rails console : >> ActiveRecord::Migration.remove_column :table_name, :column_name If you already have a migration file such as " db/migrate/20130418125100_remove_foo.rb ", you can do this: >>

How to join on subqueries using ARel?

梦想与她 提交于 2019-12-03 00:23:54
I have a few massive SQL request involving join across various models in my rails application. A single request can involve 6 to 10 tables. To run the request faster I want to use sub-queries in the joins (that way I can filter these tables before the join and reduce the columns to the ones I need). I'm trying to achieve this using ARel. I thought I found the solution to my problem there: How to do joins on subqueries in AREL within Rails , but things must have changed because I get undefined method '[]' for Arel::SelectManager . Does anybody have any idea how to achieve this (without using

Excluding files from assets:precompile in rails

假装没事ソ 提交于 2019-12-02 23:31:47
I use codekit for writing less which it then converts to css automatically. I don't want rails to convert my less files to css, I rather codekit do it. if I precompile the assets via rake assets:precompile I get rake aborted! cannot load such file -- less How do I exclude a specific folder/file types from precompiling? (all my less files are in app/assets/stylesheets/less and the css (which I do want to be precompiled) are in app/assets/stylesheets/css update deleting application.less solves this but how do I excluding it from processing in the first place? From the Asset Pipeline guide: The

How can I run SOME initializers when doing a Rails assets:precompile?

ⅰ亾dé卋堺 提交于 2019-12-02 22:46:58
Background I have an app that I recently updated to Rails 3.2.1 (from Rails 3.0.x) and have refactored the JS and CSS assets to make use of the new asset pipeline. The app is hosted on Heroku with the Celadon Cedar stack. App Config I keep application specific configuration in a YAML file called app_config.yml and load it into a global APP_CONFIG variable using an initializer: # config/initializers/load_app_config.rb app_config_contents = YAML.load_file("#{Rails.root.to_s}/config/app_config.yml") app_config_contents["default"] ||= {} APP_CONFIG = app_config_contents["default"].merge( app

Adding index :unique to a column in ruby on rails via generate migration

我怕爱的太早我们不能终老 提交于 2019-12-02 22:34:16
I know that i can touch a migration and add add_index :table_name, :column_name, :unique => true But how is the right rails migration command to generate this? rails g migration add_index_to_column_name :column_name, :unique => true Is that right? In my special example I have a table customers t.integer :customerID t.string :surname t.string :first_name t.string :phone an i want to set the customerID to unique. Tried rails g migration AddIndexToCustomers :customerID, :unique => true But if i look to my migration file after this, it dont look right see this: def change add_column :customers, :,

How to find current connection pool size on heroku

瘦欲@ 提交于 2019-12-02 22:19:10
We have a rails 3.2(.11) app with many dynos running on the heroku bamboo stack, connecting to a MySQL RDS server. There seem to be some issues with our current database connections, so we are trying to debug exactly how many connections each dyno is spinning up. I know I can set the size of a connection pool in the DATABASE_URL config on heroku, but can't seem to find out how many connections are currently being used by default. Two main questions: 1) How can I find the size of the connection pool used by heroku? 2) Is there any reason why a dyno would need a connection pool size greater than

Rails 3.2, RSpec, Factory Girl : NameError: uninitialized constant Factory

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 21:41:43
Ive been following this introductory to Rails testing and Ive run into an issue I cant seem to find the solution to. Im very familiar with Rails but this is my first foray into testing. Anyhow, I have a very basic model test, not even fully implemented and when I try and run rspec spec/models/admin_spec.rb . I get the following error in the Admin has a valid factory line (full code below) Admin has a valid factory Failure/Error: Factory.create(:admin).should be_valid NameError: uninitialized constant Factory # ./spec/models/admin_spec.rb:6:in `block (2 levels) in <top (required)>' I assume