ruby-2.1

Circular dependency detected while autoloading constant (Rails 4, Ruby 2)

早过忘川 提交于 2019-12-22 06:58:53
问题 configs/routes.rb Shutters and Paints are subresources of Jobs . resources :jobs do resources :shutters resources :paints end app/models/job.rb A Job contains many Shutters and many Paints . class Job < ActiveRecord::Base has_many :shutters, dependent: :delete_all has_many :paints, dependent: :delete_all accepts_nested_attributes_for :shutters, allow_destroy: true, :reject_if => lambda { |a| a[:no].blank? } accepts_nested_attributes_for :paints, allow_destroy: true, :reject_if => lambda { |a|

Memory usage increase with Ruby 2.1 versus Ruby 2.0 or 1.9

安稳与你 提交于 2019-12-20 11:54:32
问题 I recently deployed an upgrade of Ruby from 2.0 to 2.1.5 to my Heroku web application, and I am consistently hitting memory quota errors now, whereas with 2.0 and 1.9 this never happened. There is a limit of 512MB for a normal Heroku Dyno, and I am running 2 processes with Unicorn, along with one thread with Sidekiq across two dynos. After reading Phusion Passenger memory consumption increase from 1.9.3 (system) to 2.1.2 (RVM) on Ubuntu, I tried setting the environment variable RUBY_GC_HEAP

Ruby - Digest::Digest is deprecated; Use Digest

若如初见. 提交于 2019-12-18 03:01:35
问题 I've been getting this warning whenever I run my tests or start rails server. When I run grep from .rvm folder I see the following: grep -R 'Digest::Digest' . ./rubies/ruby-2.1.0/lib/ruby/2.1.0/openssl/digest.rb: warn('Digest::Digest is deprecated; Use Digest') - additional references to openssl and ruby 2.1.0 So it looks like it's a Ruby 2.1.0 bug. Are there any fixes? There are no patches available yet as far as I can tell. Whilst my app uses Fog and a bunch of other gems that have issues

How install ruby 2.1.0 on OS_X 10.9 using rvm? ( No binary rubies available for: osx/10.9/x86_64/ruby )

怎甘沉沦 提交于 2019-12-10 10:13:26
问题 I'm trying to install ruby 1.9.3-p545 or ruby-2.1.0 or ruby-2.1.1, but it fails... My environment: OS_X 10.9 x86_64 rvm 1.25.20 Error from terminal: bmalets$ rvm install 1.9.3-p545 Searching for binary rubies, this might take some time. No binary rubies available for: osx/10.9/x86_64/ruby-1.9.3-p545. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for osx_port. Installing macports........................................

Rails legacy app and Ruby 2 error: can not load translations from the file type yml is not known

ε祈祈猫儿з 提交于 2019-12-07 06:44:50
问题 I have a legacy Rails application which I want to upgrade to recent Rails and Ruby versions.To start with I am trying to setup the application with Ruby 2.1.2 $ rails -v Rails 2.3.18 $ ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux] When I tried to run the rake task rake db:schema:load RAILS_ENV=test I encountered following error can not load translations from /activesupport-2.3.18/lib/active_support/locale/en.yml, the file type yml is not known Searching through Google I found

How to get the name of the calling alias method?

邮差的信 提交于 2019-12-07 05:29:54
问题 I am having method called link_to_admin then I have aliased another method called simple_link_to def link_to_admin(name,url,options={}) # My stuff here link_to(name,url,options) end alias_method :simple_link_to, :link_to_admin Here I am facing one problem if I call link_to_admin , I want print the value into <li> tag Ex. def link_to_admin(name,url,options={}) # My stuff here menu = "" menu << "<li> #{link_to(name,url,options)}</li>" menu.html_safe end And if I call simple_link_to no need of

Rails legacy app and Ruby 2 error: can not load translations from the file type yml is not known

对着背影说爱祢 提交于 2019-12-05 10:55:59
I have a legacy Rails application which I want to upgrade to recent Rails and Ruby versions.To start with I am trying to setup the application with Ruby 2.1.2 $ rails -v Rails 2.3.18 $ ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux] When I tried to run the rake task rake db:schema:load RAILS_ENV=test I encountered following error can not load translations from /activesupport-2.3.18/lib/active_support/locale/en.yml, the file type yml is not known Searching through Google I found the following reference https://github.com/rails/rails/issues/10514 which mentioned that there is

How to get the name of the calling alias method?

风流意气都作罢 提交于 2019-12-05 10:34:56
I am having method called link_to_admin then I have aliased another method called simple_link_to def link_to_admin(name,url,options={}) # My stuff here link_to(name,url,options) end alias_method :simple_link_to, :link_to_admin Here I am facing one problem if I call link_to_admin , I want print the value into <li> tag Ex. def link_to_admin(name,url,options={}) # My stuff here menu = "" menu << "<li> #{link_to(name,url,options)}</li>" menu.html_safe end And if I call simple_link_to no need of <li> tag. So currently I am passing one options like li_required then am checking condition in my method

DBI Row / delegate behavior between ruby 1.8.7 and 2.1

╄→гoц情女王★ 提交于 2019-12-04 14:22:47
I execute the following code in ruby 1.8.7 to read rows from my database: require 'dbi' db_conn_handle = DBI.connect("DBI:Mysql:host=localhost;database=mydb;port=3306", "root") sth = db_conn_handle.prepare("select accounts.id, accounts.name from accounts;") sth.execute info = sth.to_a puts "Info: #{info[0].class}" info.each do |x, y| puts "#{x} ... #{y}" end From the output it is clear that info[0].class is DBI::Row. This code works perfectly when executed with ruby 1.8.7 (rails 3.2.17) When I try executing it in ruby 2.1.5 / rails 3.2.17, it gives the following error: /home/rjain/.rvm/rubies

Rails 4 add new column or field in model

半腔热情 提交于 2019-12-04 03:44:14
问题 I try to add new column into existing model in rubyonrails. How can I add single or multiple field into my existing model. 回答1: if you want to add a new column then run rails generator with Add[column]To[model] format followed by column $ rails g migration AddBioToNameOfModels bio:text invoke active_record create db/migrate/YYYYMMDDHHMMSS_add_bio_to_name_of_models.rb then run rake db:migrate 来源: https://stackoverflow.com/questions/30528877/rails-4-add-new-column-or-field-in-model