small medium large xlarge

Generic-user-small
13 Dec 2008, 07:23
Terjin TJ Dhillon (13 posts)

Hi Sam and everyone else!

I have just begun to get back into rails again and I thought what a better way then to start off perusing the content of the book that got me into rails in the first place? So I have been reading and coding away now that I have time on my hands.

I am still in the early stages of the book, and I noticed a deprecation warning in the logs when the index method in the products controller is called.

Its basically warning us about the truncate method that ActionView provides us with.

The current beta 1.6 has this as the code to display the product description… truncate(product.description.gsub(/<.*?>/,’’), 80)

The modified truncate method uses a hash of options instead. Here is the code that I used to get it to not throw a deprecation warning again.

truncate(product.description.gsub(/<.*?>/,’’), :length => 80, :omission => “….”)

I hope this helps anyone else who were wondering whats up with the warning. I should also note that I am running the app on Rails 2.2.2! Maybe thats why it was not changed yet!

Good to know nevertheless!

Cheers, Terjin

Samr_small_pragsmall
16 Dec 2008, 02:19
Sam Ruby (634 posts)

Thanks! I’ll fix that in the next beta.

You must be logged in to comment