small medium large xlarge

20 Mar 2009, 20:53
Oleksandr Manenko (3 posts)


In page 92 we change look of depot/app/views/products/index.html.erb. In example we can see this:

<dd><%=h truncate(product.description.gsub(/<.*?>/,''),
      :length => 80) %></dd>

But I got error: undefined method `-‘ for {:length=>80}:Hash

Yes, I have been read this:

bq. If you get a message such as undefined method ’-’ for {:length=>80}:Hash, then you probably aren’t running Rails 2.2.2 or later. See Chapter 3, Installing Rails, on page 31 for upgrade information, or simply remove :length => from this call (leaving the 80).

But ‘rails -v’ returns ‘2.3.2’, so I have ‘Rails 2.2.2 or later’.

Can anyone help? Thanks and sorry for my bad English.

20 Mar 2009, 21:21
Sam Ruby (633 posts)

What does it say when you run “ruby script/console”? If different than what rails -v returns:

Look for a line that starts with “RAILS_GEM_VERSION” in config/environment.rb. What does it say?

Also look for a directory named “rails” in your vendor directory. If present, that’s the version you actually are running.

20 Mar 2009, 22:48
Oleksandr Manenko (3 posts)

Yes, problem was in RAILS_GEM_VERSION. Thanks!

04 May 2010, 21:36
Mario Sergio M. Santos (1 post)

Hey Alexander, I guess you were using Instant Rails 2.0 or earlier, and I found out that this package does not come with the latest version of Rails because that’s what happened here.

Well, I checked the real Rails version of this IR2.0 package and it is running the Rails 2.0.2 and I guess that the version I’m talking about does not recognize the method truncate and if we remove it, everything will work just fine.

I know that it is already 2010, but someone might get here for the same reason that I just did. Let’s have fun!

You must be logged in to comment