ruby

Can anyone tell, how to create exerb.exe for 4.2.0 version from the exerb_4.2.0.zip(set up)

Can anyone tell, how to create exerb.exe for 4.2.0 version from the exerb_4.2.0.zip(set up) ...

Talking with a SOAP service using Savon gem in Ruby

I'm trying to communicate with a soap service and I know that I should send a SOAP Envelope like this: POST /webpay_test/SveaWebPay.asmx HTTP/1.1 Host: webservices.sveaekonomi.se Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "https://webservices.sveaekonomi.se/webpay/CreateOrder" <?xml version="1.0" encoding...

Is it safe to run a ruby script using sudo ?

I am running redmine on Ubuntu, and I am running it using sudo. If I try to run as my redmine user, I get permission errors on the log file. Is this safe? Should I be concerned? ...

ruby lambda context

Lets say I have the following ruby definition at the topmost level callable = lambda {"#{hi}"} and suppose that later on I create an object called temp that has a method called hi. Now what I would like to do is call callable within the context of temp. I have tried doing temp.instance_eval do callable.call end but this gives me th...

Rubyamf with attachment_fu problem.

This my class test. has_attachment :storage => :file_system, :max_size => 1.megabytes Rubyamf_config.rb ClassMappings.register( :actionscript => 'TestVO', :ruby => 'Test', :type => 'active_record', :methods => ["created_at","has_attachment"], :attributes => ["id","document_uri", "lock_version"]...

TCPServer socket in ruby

hi, I would like to establish a connection between 2 computers using socket. For this purpose one of them is a server and this is the code I've write: sock= TCPServer.open('localhost', 6666) sock.accept the client try to establish the connection: client = TCPSocket.open(ip_server, 6666) but is not working. I've notice scanning serv...

Ruby: Multiply many variables with the same name

Hi. I'm new to ruby. Is there any way how can I shorten this code? Thanks plans.each do |plan| total = plan.landline.to_f * @landline.to_f total += plan.vpn.to_f * @vpn.to_f total += plan.other_networks.to_f * @other_networks.to_f total += plan.gprs.to_f * @gprs.to_f total += plan.sms.to_f * @sms.to_f total += plan.mms.to_...

Ruby routes and link_to, custom :action route problem

Hello, I'm trying to get this link: <%= link_to('Edit', :action => 'manage', :id => user) %> even tried explicitly <%= link_to('Edit', {:controller => 'users', :action => 'manage', :id => user}, :method => :get) %> to show the link in HTML as '/users/manage/1' or '/users/1/manage' but it shows up as '/users/manage?id=1' I ca...

Return ActiveRecord query as variable, not hash?

I am doing an ActiveRecord find on a model as such @foo = MyModel.find(:all, :select => 'year') As you can see, I only need the year column from this, so my ideal output would be ["2008", "2009", "2010"] Instead, though, I get an a hash of the models, with each one containing the year, as such: [#<MyModel year: "2008">, #<MyModel ...

SVG files in Raphael, can they be used?

I have an SVG file that I would like to display via Raphael (each svg file is a node in a tree I'm trying to draw, the actual connections of the tree will be made by raphael). I tried something like: var vector_image = paper.image("test.svg", 50,50,50,50); but no dice, seems only "real" image files like png or jpeg are accepted? I fi...

Programmatically derive a regular expression from a string.

I would like to input a string and return a regular expression that can be used to describe the string's structure. The regex will be used to find more strings of the same structure as the first. This is intentionally ambiguous because I will certainly miss a case that someone in the SO community will catch. Please post any and all po...

Difference between attr_accessor and attr_accessible

Hi, In RoR, what is the difference between attr_accessor and attr_accessible. From my understanding, using attr_accessor is used to create getter and setter methods for that variable, so that we can access the variable like `Object.variable` or `Object.variable = some_value` I read that attr_accessible makes that specific variab...

Discovering capabilities of Ruby gem

Hello, The Ruby (and RoR) community publishes a large number of gems. But more often than not using these gems requires a good amount of effort, specially if one is new to Ruby. It would to be nice if Ruby experts (rockstars) share the best approaches to utilize inadequately documented gems. Thanks --arsh ...

Ruby FFI on MinGW

I built a (very simple) library, which I can call just fine from another C++ program. But it won't work when I try to get Ruby FFI to link it. It gives FFI::NotFoundError, says it can't find the function exported in the DLL. Where might things have gone wrong? Do I need special treatment when I compile my DLL using g++? I am just bu...

In Rails Routes redirect /:controller_name to root?

I have a root path in my routes file: map.root :controller => 'games', :action => 'index' The problem is that if anyone goes to: http://domain.com/games it doesn't show the root, thus we're creating two urls for the same page. Is there a way to change any hit to http://domain.com/games to http://domain.com ? I'd rather not fiddle arou...

How to create PI sequentially in Ruby..

Out of pure interested, I'm curious how to create PI sequentially so that instead of the number being produced after the outcome of the process, allow the numbers to display as the process itself is being generated. If this is the case, then the number could produce itself, and I could implement garbage collection on previously seen numb...

default data in fckeditor with jQuery

I have following code in my view. = fckeditor_textarea("newsletter", "info", :toolbarSet => 'Simple', :width => '100%', :height => '400px') In my controller I have created an object for that which contains value. @newsletter = Newsletter.last But in display data is not loaded in fckeditor. So, how to do that? ...

How to manually build a universal ruby on Mac OS X? How about with rvm?

I got the ruby sources from the official git mirror, then checked out the ruby_1_9_2 branch. git clone http://github.com/ruby/ruby.git git checkout ruby_1_9_2 So, for now, I want to compile 1.9.2-head. But as you'll see later I'm hoping for a solution that works for 1.8 too. The standard way to compile this is: autoconf ./configu...

Rails: Mapping Conflicting Routes by Detecting Param

Hey! I am trying to set up routes in a Rails application so that, depending on the type of parameter passed, Rails sends the request to a different action. I have courses which have an attribute state which is a string with a two letter state abbreviation. When a user visits /courses/1, I want Rails to display the show action in the co...

What does a rack handler do exactly?

What does a rack handler do exactly, i.e. can someone explain in pseudo-code the steps that a rack handler takes to deliver a result for a request? ...