ruby

Ruby Subversion Bindings - No method error

I am working on a Subversion library and the first step is the checkout method. I have written a test for it that fails with the following error, which I do not understand. Can you help me figure out what happens? test_Checkout(SvnTest): NoMethodError: undefined method ` ' for #<Subversion:0x1054e6438> lib/svn.rb:23:in `checkout' ...

How can I renew access token in Ruby OAuth gem?

Hi, I am trying to renew my access token using Ruby OAuth gem. I wrote my custom method, but it does not work. Has anyone tried renewing the access token using the OAuth gem? If yes, then how? ...

How to control mutil daemons processes in ruby?

How to start many processes(will run the same script) by "Daemons gem", and how to stop one of them as I want ? thanks! ...

Ruby Class 500 Error

Why is this not correct. What is wrong with it?? #!/usr/bin/ruby require "mysql" class Game attr_accessor :id, :name, :urlName, :description, :hits, :categorys, :width, :height, :nilGame def load(id) #Load mysql begin # connect to the MySQL server con = Mysql.new('localhost', 'user', 'pass', 'database') ...

Ruby & Syslog & custom facility

I'm very new playing with syslog. We have decide to use syslog to track some especial events on our Rails application. The point is that I don't want to use the default /var/log/system.log file but use a custom one like /var/log/myapp_events.log. I see that for that I have to define my own facility into the /etc/syslog.conf like this:...

Validate uniqueness on combined fields in DataMapper

Hi. I want to be able to put entries in my database where the manufacturer will be represented multiple times but not the same combination of manufacturer and model. So "Sony(manufacturer), Tv(model)" is okay "Sony(manufacturer), OtherTv(model)" but the third entry "Sony(manufacturer), Tv(model)" is not okay since the combination of manu...

Ruby regexp help

Hi, I need help to remove the string /* s */ (comments in .c and .h files) from some files using Ruby. Is it correct to use gsub to do this. I know that this string is always placed at the beginning av a line. thx. ...

How to use a branch in a fork of rails in a project with bundler

I've got a fork of the rails repo on github, in which I've got a branch, based on the rails-2-3-stable branch. I want to develop some changes based on rails 2.3.10 together with my app. We're using bundler, and the app is versioned with SVN. What is the cleanest way to use my branch in the github fork of rails and share this across mach...

Ruby/Rails/PostgreSQL PGError: syntax error at or near

I'm getting the error in the title when trying to select a cookie value from a table in a postgresql database, and I've no idea why. Selecting other fields in this table work fine. Here's the line where it is breaking: user=UniqueUser.find(:all, :select => 'DISTINCT visitor_id', :conditions=> "visitor_id=#{visitorid}") The column is...

Ruby.vim indent fails with each..do leading with regex containing a hash ('#')

I'm editing Ruby code in Vim. There is a failure in the Ruby.vim indentation which is bugging me. Here is a block of code with correct indentation: text.scan(/#/).each do |match| line1 line2 end Here is how Ruby.vim indents the code: text.scan(/#/).each do |match| line1 line2 end All lines subsequent to line2 are inden...

How can I update parts of the string that matches some regexp

Hi, I have string "(1,2,3,4,5,6),(1,2,3)" I would like to change it to "('1','2','3','4','5','6'),('1','2','3')" - replase all parts that mathces /([^,)("])/ with the '$1', '$2' etc ...

Logging partial times in production

Is it possible to just log partial times without turning on all logging with? config.log_level = :debug I just want to see partial times as all the others seem under control and don't want to slow down the application to get this logging. ...

Paperclip :style depending on model (has_many polymorphic images)

Hello, I have set up my models to use a polymorphic Image model. This is working fine, however I am wondering if it is possible to change the :styles setting for each model. Found some examples using STI (Model < Image) However this is not an option for me, because I am using a has_many relation. Art has_many :images, :as => :imageabl...

Why am I getting NoMethodError from IRB for my own Module and method

Hi, I have taken this example exactly from the Ruby Cookbook. Unfortunately for me, like a whole lot of the examples in that book, this one does not work: my file (Find.rb - saved both locally and to Ruby\bin): require 'find' module Find def match(*paths) matched=[] find(*paths) { |path| matched << path if yield...

How to disable stdin echo in windows console

I'm writting a Ruby program for windows, and I need to read user input from keyboard (stdin). However, it's needed that the user key-presses are not automatically displayed in the windows console, and behave like "silent key presses" This problem in Ruby over linux, can be solved using the "stty" linux command: %x{stty -icanon -echo} ...

config undefined in environment specific configuration files

When I start my server locally, I get the following notice: please set config.active_support.deprecation to :log at config/environments/development.rb When I add in config/environments/development.rb config.active_support.deprecation = :log I get: undefined local variable or method `config' for main:Object (NameError) my envir...

How to change all the keys of a hash by a new set of given keys ?

Hi How to change all the keys of a hash by a new set of given keys ? Is there a way to do that elegantly ? Thx JCLL ...

How calculate the day of the week of a date in ruby?

How calculate the day of the week of a date in ruby? For example, October 28 of 2010 is = Thursday ...

Getting latest memcached gem to build on Snow Leopard

I've tried everything I can find on every website out there, and I can not get this to build. $ ruby --version ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0] Full error: http://gist.github.com/651945 Entire build: http://gist.github.com/651952 ...

Best practices for releasing objects in ruby

Let´s say I have a logger class that has an attribute pointing to an open file. This file should be open until this class is no longer used. Something like: class MyLogger attr_accessor :log_file def initialize @log_file = File.new('my_log_file_name.log','w') end def finalize(id) @log_file.close end end How can I en...