Showing posts with label rails. Show all posts
Showing posts with label rails. Show all posts

Friday, January 23, 2009

svn: This client is too old to work with working copy; please get a newer Subversion client

When I tried downloading the latest ActiveScaffold plug-in (script/plugin install git://github.com/activescaffold/active_scaffold.git -r rails-2.2 ) for my rails app. I got this error
svn: This client is too old to work with working copy;
please get a newer Subversion client
I check my svn version and I was running 1.4.6.28521. I downloaded the client from the CollabNet website http://www.open.collab.net/downloads/subversion/ and installed it. At the installer I had to change the install path to match my old installation folder(C:\Program Files\Subversion).

After upgrading to svn version 1.5 i was able to run the plug-in update without any errors.

Wednesday, January 21, 2009

Rails Error: Rails requires RubyGems >= 1.3.1 (you have 1.2.0).

I tried setting up a new rails project today. After I updated to the new rails version 2.2.2, I got the following error when attempting to run my WEBrick server.

"Rails requires RubyGems >= 1.3.1 (you have 1.2.0). Please `gem update --system` and try again.

So I did what It said.

gem update --system
and it returned 'Nothing to Update'

I solved this problem by running
gem install rubygems-update
and then...
update_rubygems

that actually did the updating.
After the gem updates I was back in business.

Monday, August 25, 2008

Error starting rails WEBRick server - ActionController::Caching::Fragments::MemCacheStore (NameError)

I go into error when trying to update my gems this week. After an unsuccessful gem update I found my self with the following error when trying to run my WEBRick server.


c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant

ActionController::Caching::Fragments::MemCacheStore (NameError)


I checked to see if my memcached-client was installed and it was there. I compared with another developer and the same files were there. After unsuccessful debugging I took the choice to uninstall the entire ruby language and also rails framework.

I follow this tutorial http://tubecaption.com/watch?v=c0jR_hptpdA that demonstrate the order of how to uninstall / remove your gems.

Monday, June 02, 2008

ruby on rails: will_paginate anchor param

Recently I discover that I can add an anchor to the will_paginate helper for the will_paginate plugin in rails.

This will create the url as "path/?page=2#myanchor".




<%= will_paginate @videos, :params => {:anchor => "myanchor" }%>


Wednesday, May 28, 2008

Ruby: Display datetime - time in words - timeago helper function.

I found this function on the web and putted right into my helper class to display DateTime or Time into words. Displaying time in words is now more used on the web. Popular pages such as YouTube and Yahoo videos use this approach.

Copy the code and plugged into your helper class.




def timeago(time, options = {})
start_date = options.delete(:start_date) || Time.new
date_format = options.delete(:date_format) || :default
delta_minutes = (start_date.to_i - time.to_i).floor / 60
if delta_minutes.abs <= (8724*60)
distance = distance_of_time_in_words(delta_minutes)
if delta_minutes < 0
return "#{distance} from now"
else
return "#{distance} ago"
end
else
return "on #{DateTime.now.to_formatted_s(date_format)}"
end
end
def distance_of_time_in_words(minutes)
case
when minutes < 1
"less than a minute"
when minutes < 50
pluralize(minutes, "minute")
when minutes < 90
"about one hour"
when minutes < 1080
"#{(minutes / 60).round} hours"
when minutes < 1440
"one day"
when minutes < 2880
"about one day"
else
"#{(minutes / 1440).round} days"
end
end

Tuesday, May 27, 2008

Ruby: Format seconds into minutes to_minutes function

I created this function to turn seconds into minutes.
Example: 500 seconds should be displayed as 8:00 minutes.




def to_minutes(seconds)

m = (seconds/60).floor
s = (seconds - (m * 60)).round

# add leading zero to one-digit minute
if m < 10
m = "0#{m}"
end
# add leading zero to one-digit second
if s < 10
s = "0#{s}"
end
# return formatted time
return "#{m}:#{s}"
end