Replacing the 'auto_link' method in Ruby on Rails 3.1 - ruby-on-rails

I am using Ruby on Rails 3.0.7 and I know that in the 3.1 version there won't be the auto_link method anymore (see the actionpack/lib/action_view/helpers/text_helper.rb for RoR 3.1).
Is there another way to have similar functions as the old auto_link method? That is, how can I replace that useful method in Ruby on Rails 3.1?
BTW: why will the auto_link method will be removed?

Rinku is a drop-in replacement for Rails 3.1 auto_link.
Auto-linking functionality has been removed from Rails 3.1, and is instead offered as a standalone gem, rails_autolink. You can choose to use Rinku instead.
require 'rails_rinku'
The rails_rinku package monkeypatches Rails with an auto_link method that mimics 100% the original one, parameter per parameter. It's just faster.

Not sure why, but Aaron Patterson (Rails Core team) seem to have the gem for this as well https://github.com/tenderlove/rails_autolink (which worked fine for me, YMMV)

Related

tap method in Rails 3 - Have I understood the API Docs correctly?

I'm upgrading a rails 2 application to rails 3.2 and have come across what is described as an idiom.
person.tap |p| do
When I Googled for this and it appears to have been deprecated or moved. Is my understanding correct?
I ask because I can find a few examples of it on SO.
The tap method has been in Ruby since 1.8.7:
tap{|x|...} => obj
Yields x to the block, and then returns x. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.
Note that 1.8.6 did not have Object#tap. Presumably, tap was in older versions of Rails (as a monkey patch on Object) but was added to Ruby itself in 1.8.7. Since 1.8.6 is rather ancient now, the Rails version was deprecated and, in more recent Rails releases, removed entirely.
Object#tap is still around so tap itself has not been deprecated, just the Rails monkey patched version has been removed.
The Object#tap monkey patch from ActiveSupport is deprecated because it has been part of Ruby since 1.9.0 and 1.8.7.

Rails 3.2: Undefined method 'class_inheritable_accessor' in activemerchant

I'm building my first Rails app and trying to integrate active_paypal_adaptive_payment with Rails 3.2.1, however when I try to boot up the rails server it runs into the problem of, "undefined method 'class_inheritable_accessor' (in line 4 of post_date.rb) in the activemerchant-1.5.1 gem of which is a dependency.
I've looked around and seems this method has been removed in rails 3.2. From what I understand, it's not as simple as going into the activemerchant gem and replacing class_inheritable_accessor with class_attribute (read this conversation).
Any ideas on how I could update this gem so it could be compatible with Rails 3.2? It's an outstanding issue on the github page so appreciate any help with it!
This particular commit solved my issue: https://github.com/cmezak/active_paypal_adaptive_payment/commit/c6661704c45b73a0be5c608c673b106ac1eb5b69

Any suggestion for a stable and compatible version of Ruby on rails

Ok, there are similar question about this but I'm going a little bit further. I started working with Rails 3.2 but many of the things I wanted to do were not yet compatible. For example I was following the exercises of a book and there were using prototype and effect, things that are deprecated in Rails 3.2, I know I can switch between version, but If you would have to start a serious project and you would like to go through the painless way, which environment would you use?
Rails, Ruby, Prototype or Jquery,coffeescript or js, Sass or css, js.erb or rjs.erb...etc etc...
I know companies that are still using Rails 2.2 because the know exactly the version and their compatibilities.
Prototype isn't deprecated, it just isn't the default js library included in Rails 3.1.
Use the prototype-rails gem if you want to use prototype.
https://github.com/rails/prototype-rails
If your book was using prototype then it's most likely very out of date.
Here's a great tutorial for Rails 3.2:
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book?version=3.2

Ruby 3.0 isn't compatible with lower version?

Now I am studying Ruby on Rails in Ruby 1.9.3 environment.
But I saw many articles that ruby 1.x sources doesn't work in ruby 2.0 and 3.0.
If so, is it mean that I have to study again Ruby 2.0 or 3.0 when Ruby on Rails has been updated to run under Ruby 2.0 or 3.0?
Thank you in advance!
You're confusing Ruby on Rails with Ruby. There is no Ruby 3.0, but there is a Ruby on Rails 3.0.
The current versions of Ruby are: 1.8.7, 1.9.2 and 1.9.3 which was just released.
The current versions of Rails are: 2.3.14, 3.0.10, and 3.1.1.
Ruby 2.0 hasn't seen a release yet and remains a theoretical construct at this point.
Ruby is to Rails as Javascript is to Jquery.
One is a language, and the other is really just a bunch of files (scripts, like in a play) that handle a lot of background jobs and tasks that you might need done when building a Ruby application. Rails is more commonly referred to as a framework, it's really just a pattern or paradigm for helping you structure your code.
To make more sense of this, you could try using an alternate framework to Rails, like Padrino, which is written in Ruby too, but is not Rails. It's Padrino. Same idea, ostensibly.
I recommend reading a very simple vanilla book on Ruby, which goes nowhere near any of the frameworks, like this one by Zed Shaw (which was not originally written for Ruby and so doesn't really go into the more complex and exciting stuff for which Ruby is known, like metaprogramming) but which will give you a broad based insight into how it works.
Then, in a month or so, move on to Rails Tutorial. Good luck.

Source for updated rails engines

What is the source (url) for Rails Engines that works with rails 2.2.2?
I'd get the current source from github and search for "engine".
It looks like the Rails Guides did not start until Rails 2.3.8. I could not find guides for anything less than Rails 2.3.8.
http://guides.rubyonrails.org/v2.3.8.
Additionally, Rails Engines were something introduced in Rails 2.3, though similar functionality may have been present in Rails 2.2 through Plugins.
http://railscasts.com/episodes/149-rails-engines?autoplay=false

Resources