I had a exception when I switch to Ruby 1.8.7 on Snow Leopard
ArgumentError: wrong number of arguments (1 for 0)
/Library/Ruby/Gems/1.8/gems/activerecord-1.15.5/lib/active_record/connection_adapters/abstract/quoting.rb:27:in 'to_s'
/Library/Ruby/Gems/1.8/gems/activerecord-1.15.5/lib/active_record/connection_adapters/abstract/quoting.rb:27:in 'quote'
/Library/Ruby/Gems/1.8/gems/activerecord-1.15.5/lib/active_record/connection_adapters/mysql_adapter.rb:190:in 'quote'
/Library/Ruby/Gems/1.8/gems/activerecord-1.15.5/lib/active_record/base.rb:2042:in 'quote_value'
/Library/Ruby/Gems/1.8/gems/activerecord-1.15.5/lib/active_record/base.rb:2034:in 'attributes_with_quotes'
Application uses Rails 1.2.5: there is no chance to update rails in this app. Somebody have solution?
There will be a lot of compatibility issues with such an old version of rails and ruby 1.8.7. I would suggest using rvm to install multiple ruby versions / rails versions to test your app. I would also look into security patches as I am not sure if they are being backported to the 1.2.x branches.
I put this in a file inside config/initializers
class ::DateTime
alias_method :to_s, :to_formatted_s
end
Related
In ~/src/project/ containing all the files, I'm attempting to run bundle and bundle install, but it tells me I need a gem called "buff-extensions" and that gem installer requires Ruby version >= 2.2.0 to work properly.
When I ran ruby --version, it said Ruby 2.2.4p230 is being used when run from that directory.
I know there are several versions of Ruby on the machine in several places, and I'm struggling to follow the paths and figure out which technology is using which piece.
The Bundler docs spell this out:
You can specify the required version of Ruby in the Gemfile with ruby. If the Gemfile is loaded on a different Ruby version, Bundler will raise an exception with an explanation.
ruby '1.9.3'
What this means is that this app has a dependency to a Ruby VM that is ABI compatible with 1.9.3. If the version check does not match, Bundler will raise an exception. This will ensure the running code matches. You can be more specific with the :engine and :engine_version options.
ruby '1.9.3', :engine => 'jruby', :engine_version => '1.6.7'
I finally figured out the exact incantation in order to get the intended result, and I now realize the situation is unreasonable to expect any stranger to attempt to answer.
It involved chef, and I was supposed to run chef exec bundle.
I have multiple Rails apps from 3.2.14 to 3.2.18 in my development environment. I'm using Ruby 1.9.3 (yes, I know) for these apps and it's installed and managed via rbenv. I'm about to build a couple of new apps with Rails 4.1 and Ruby 2.1. My question is, what is the best way to handle installing multiple versions of Ruby using rbenv. Currently 1.9.3 is set to global, but I want different Rails apps (4.1) to use Ruby 2.1.
I guess I'm a bit behind the curve with Ruby management so I could use a hand here. Again, looking to have multiple Rails apps (different versions 3.2.14-4.1.x) and multiple Ruby instances to support each app.
I appreciate the help in advance.
Create a .ruby-version file in your application root directory and specify the ruby version you want. For instance, if you want one application to use 1.9.3 and the other 2.1.0, you'll have a .ruby-version file each in those two applications, specifying the version:
/application1/.ruby-version
1.9.3
/application2/.ruby-version
2.1.0
Update
For every installed version of ruby, you'll have a shims directory which will house all your gems for that particular version. When you switch between ruby versions, rbenv will simply set the environment variables to the one you select.
In the example above, I set the local ruby version for the directory ruby_cookbook to 2.1.2 and a gem list will only show gems installed for 2.1.2.
I also created a .ruby-version with ruby version 1.9.3-p547 in my try_stuff directory. As you can see, gem list only shows gems installed for 1.9.3.
The gems you install are specific to the current version of ruby.
If your project root has a .ruby-version file, your environment will automatically set the current ruby version to the one specified. So, yes, your production environment will need the version you mention in your .ruby-version. If you use git for source control, you can add that file to your .git-ignore and you won't see it in your prod version.
I know it's possible to get the Ruby version (e.g. "1.9.3") via the RUBY_VERSION constant. However, I want to know how to go about determining the exact version (e.g.: "1.9.3-p0"). The reason is that there is a bug that was not fixed in earlier versions of Ruby 1.9.3 that is working in later versions, and I want some code in a gem I'm working on to account for this.
There is a RUBY_PATCHLEVEL constant as well. So you can get your version string as
"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
At least in the newest Ruby (2.3.0), there is also a RUBY_DESCRIPTION constant:
RUBY_DESCRIPTION
# => "ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]"
I have developed a simple ruby application without any MVC, and runs on command prompt using ruby 1.9.2 . It also has a Gemfile. I want this application to run on machines running ruby 1.8.7 and 1.9.3 as well. So how can I set it right for multiple environments.
Please Guide.
Thanks
At first you have to make sure that your code is compatible with the syntax of ruby 1.8 and 1.9 https://stackoverflow.com/a/21621/335523
Then make sure that the gems you used support both versions of ruby. (Read through their github page or documentation)
If you are using gems that do not suport both versions of ruby you have to find alternative gems that provide the same functionality in each environment and specify them in your gem file like this:
gem 'rcov', :platforms => :ruby_18
gem 'simplecov', :platforms => :ruby_19
I am getting an error when i am running any sort of rake command , it is showing me
rake aborted!
no such file to load -- config/environment
I am trying to upgrade the ruby version from ruby 1.8.7 to ruby 1.9.2 and rails 2.3.11 to rails 3.0.9 and when i am trying to start the server it is showing me
Value assigned to config.time_zone not recognized.Run "rake -D time" for a list of tasks for finding appropriate time zone names. (RuntimeError)
I am using RVM for this upgrade
ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
rails -v
Rails 3.0.9
You can't just upgrade from Rails 2 to 3 without some rather extensive preparation. All hell will break loose. Check out these Railscasts for starters:
http://railscasts.com/episodes/225-upgrading-to-rails-3-part-1
http://railscasts.com/episodes/226-upgrading-to-rails-3-part-2
http://railscasts.com/episodes/227-upgrading-to-rails-3-part-3
There might be newer resources out there. I'd also suggest to upgrade first ruby and then Rails, or vice versa, not both at the same time. Divide and conquer.
Peepcode Rails 3 Upgrade Handbook PDF
Rails Core suggestions: Plugin to run checks on your Rails 2.x/3.x to check for obvious upgrade points on the path to 3.0.