ruby

How do I pass objects to RPC style web services when working with soap4r at runtime?

I am creating a proxy for a soap web service at runtime using soap4r. proxy = SOAP::WSDLDriverFactory.new("http://www.example.com/endpoint?wsdl).create_rpc_driver How do I execute a rpc with a object parameter? Any examples would be very helpful. Thanks. ...

Rails views inconsistently rendered

I like how Rails gives me flexibility in naming view files, ie index.erb or index.html.erb essentially do the same thing. The problem is that I've merged two separate projects, where one uses filename.erb for all its views and the other uses filename.html.erb. It seems that Rails expects only one naming scheme as I keep getting missing...

How to invoke a rake task from within a test program

I am not trying to test rake tasks. I have a test program which sends out emails ( real emails yes) to test email templates etc. class EmailTemplatesTest < ActiveSupport::TestCase context 'send_password_info' do setup do Emailtb.send_password_info(user) Rake::Task['email:run'].invoke # this actually delivers email ...

ruby "each do" and scriptaculous Effect.BlindDown/Up

I have a list of items with some details that I would like to reveal upon clicking a show/hide details link. after some experimenting, I've come across two issues. I'm having trouble making it so that the show/hide link only reveals the div of a specific item. right now, it is revealing all of the divs when clicking any of the show/h...

Restart ruby program

I am writing an IRC bot and my intention is to have "!reboot" reboot the bot. I have already got it to part from a channel and break the running loop, but I cannot get it to re-run the file. It needs to start a new process and load up a new version of the file, so that any new commands etc. and configuration changes can be loaded. ...

Are there any Ruby gems for easy to do image uploading?

Possible Duplicates: Uploading files in Ruby on Rails Uploading files in Rails Uploading Pictures Ruby on Rails I am doing a web site which allow users to upload images, is there any way to simplify the upload process? ...

Can't upload photo using paper clip...

I used paper clip in my web application, I use this to make a new product: <% semantic_form_for @product do |f| %> <% f.inputs do %> <%= f.input :title %> <%= f.input :price %> <%= f.file_field :photo %> <%= f.input :category , :include_blank => false %> <% end %> <%= f.buttons %> <% end %> And th...

Translating function for finding all partitions of a set from python to ruby

I have the following python function to recursively find all partitions of a set: def partitions(set_): if not set_: yield [] return for i in xrange(2**len(set_)/2): parts = [set(), set()] for item in set_: parts[i&1].add(item) i >>= 1 for b in partitions(parts[1]):...

Anybody using ruby without any framework?

I am experimenting with Ruby and Rails. I like Ruby, but not Rails. I have Java/PHP background, I have used some frameworks, but never totally liked any of them. Anybody using Ruby to build web apps, but not any of the frameworks? (rails, merb etc). If yes, can you point me to some resources to learn it? ...

Ruby on Rails: Creating child objects

I'm sure this is a very simple question, but I'm just a newbie so... I have a model, Game, which has_many :piles. Pile, in turn, has_many :cards. I'm able to populate the Piles and Cards at creation of the Game, so my code at present looks something like: class Game < ActiveRecord::Base has_many :piles def after_create 1.upto(...

Ruby multiple named arguments

Hello, I'm very new to ruby and I'm trying to write a web application using the rails framework. Through reading I've seen methods being called like this: some_method "first argument", :other_arg => "value1", :other_arg2 => "value2" Where you can pass an unlimited number of arguments. How do you create a method in ruby that can be u...

How to properly join LF character in an array?

Basic question. Instead of adding '\n' between the elements: >> puts "#{[1, 2, 3].join('\n')}" 1\n2\n3 I need to actually add the line feed character, so the output I expect when printing it would be: 1 2 3 What's the best way to do that in Ruby? ...

Join array contents into an 'English list'

I like to join an array resulting in an 'English list'. For example ['one', 'two', 'three'] should result in 'one, two and three'. I wrote this code to achieve it (assuming that the array is not empty, which is not the case in my situation) if array.length == 1 result = array[0] else result = "#{array[0, array.length].join(', ')} a...

Ruby class_eval method

I'm trying to figure out how to dynamically create methods class MyClass def initialize(dynamic_methods) @arr = Array.new(dynamic_methods) @arr.each { |m| self.class.class_eval do def m(*value) puts value end end } end end tmp = MyClass.new ['method1', 'method2', 'method3'] Unf...

Adding Children with awesome_nested_set in rails

How do I add children to a parent using the awesome_nested_set plugin? I have a model, Unit, which is a nested set. I'd like to add sub-units. Within the edit view, how I let the user add children (sub-units) to the parent (unit)? ...

Is there a simple way to duplicate a multi-dimensional array in Ruby?

I have a 2-dimensional array in Ruby that I want to produce a working duplicate of. Obviously I can't do this; array=[[3,4],[5,9],[10,2],[11,3]] temp_array=array as any modifications I make to temp_array will also be made to array, as I have merely copied the object identifier. I thought I would be able to get around this by simply us...

Can Ruby + Crate + Windows work?

I've got a project for work I'd like to do in Ruby that will have to run on Windows, but perturbing the filesystem for a Ruby install or RubyScript2Exe unpack isn't an option (this is supposed to be the harness for a testing system). Has anyone successfully used Crate to package up something on Windows? If so, what was your build envi...

Ruby Integer(), Array(), et al -- what are they? Where do they come from?

I've come across conversions of the form Array(value), String(value), and Integer(value) on occasion. It appears to me that these are just syntactic sugar for a call to the corresponding value.to_a, value.to_s, or value.to_i methods. So I'm wondering: Where/how are these are defined? I can't find them in Object, Module, Class, etc A...

Ruby block parameter error

class MyClass def test ... end end tmp = MyClass.new tmp.test do |t| "here" end Why am I getting the error multiple values for a block parameter (0 for 1) ...

What are the current resources for building a Facebook application with Rails?

I'm looking to build a basic Facebook application with Rails. What are the resources (books podcasts, screencasts, blog articles etc) that you'd recommend? (One answer per post please, and up-vote instead of duplicate). ...