ruby

Convert SVG to PNG in Ruby

I need to convert SVG content to a raster image (preferably a PNG) in a RoR app. Is there a direct method that doesn't involve ImageMagick, or is this the de facto standard? ...

What is the best Ruby pattern to use in this Rails situation?

The interaction of the site is based on the input of user. For example, if the user selected "VISA" as payment method, he will be redirected to another controller/actions asking for credit card number. If the user selected "Paypal", then he/she will be redirected to an external website. Instead of putting all logic in the action itself...

Grouped Select in Rails

Simple question really - how do I use the select(ActionView::Helpers::FormOptionsHelper) with grouped options? I have got it working with a select_tag (ActionView::Helpers::FormTagHelper) but I would really like to have it using a select tag to match the rest of the form. Is this possible? My options look like this: [ ['Group 1', [...

jRails Alternative

Hello, do you know an alternative to jrails? It's more or less outdated (uses jQuery 1.5 - now 1.7 is the current release). Does anybody know an alternative? Thanks EDIT: I know how to build the rails helper with jquery allone - but I like the rails helpers, so I dont want to use jquery allone (without jrails) ...

Best method to send programmed emails from web application

I want to send emails through a web app, for example, reminders of a tasks manager, reminders of birthdays... I want to program a date and an hour, and get the email sent at that moment. I think I have two options to do this: using cron or sending email with a future timestamp. Using cron involve to run a command (which will query the ...

Gem-idea: Automatic spam protection with captcha in before_filter when HTTP-method is post,put or delete

I'm thinking about writing an automatic spam protection system (maybe I will write a public gem) for rails. My concept is to include a helper method in application_controller f.e.: class ApplicationController < ActionController::Base automatic_captcha_redirect(:min_time => 30.seconds :limit => 50) ... end Then I want to include aut...

How Does Ruby handle bytes/binary?

I'm trying to send a series of binary bytes across a socket, to meet a particular standard my company uses. No one in my company has used Ruby for this before, but in other languages, they send the data across one byte at a time, (usually with some sort of "pack" method). I can't find anyway to create binary on the fly, or create bytes...

Where can I find a decent Ruby source beautifier?

Where can I find a decent Ruby source beautifier? I want something customizable and reliable. I found this but I'm not convinced. ...

"patch" rails render function to edit default options..

when I render :xml in rails I always want the :dasherize => false options. Is there a way to set it application wide as the default, without having to modify rails source code of course? maybe a render function that somehow takes precedence over the first one and then calls it with this option... ...

page.insert_html does not insert html with link_to_function (rails)

Hi there, I'm triying to do a complex form in Ruby On Rails. It should be divided in groups, and each group should have text fields. I want groups and text fields to be added and removed dinamically. I already managed to get Text Fields added and removed dinamically, but I am totally unable to do the same with the groups. This is the...

What is the difference between Methods and Attributes in Ruby?

Can you give me an example? ...

How to use/fill a combo box with Ruby/Glade 3

Hey guys, I am trying to make a gui with Glade 3 (gtk) and ruby but cannot figure out how to actually populate a combo box dynamically with say a list of strings. I get the xml .glade file after i visually make my gui in Glade, and use ruby-glade-create-template to generate my .rb file but have no idea where to go from here. I cannot fi...

Sorting an array of arrays in Ruby

I have an array of arrays like so: irb(main):028:0> device_array => [["name1", "type1", ["A", "N", "N"], ["Attribute", "device_attribute"], 9], ["name2","type2", ["A", "N", "N"], ["Attribute", "device_attribute"], 7]] I would like to sort the entire device_array on the 4th element. I've tried AllDevicesController.all_devices.sort d...

Heroku eating my custom HTTP Headers

I'm using Heroku (heroku.com) to deploy my rails application, and am building an iPhone client to interface with it. My intention was to pass the unique device identifier of the phone to the app as a HTTP header for authentication. When I test locally, my headers come through fine, but on Heroku it seems to strip out my custom header. I ...

Is there a consensus about test frameworks for Ruby 1.9.x?

A two-parter with a quick intro. Intro: I'm coming to Ruby from Perl, and I'm a bit lost among the test framework choices. I understand that there is probably no single, all-around best choice, but I can't even get a clear picture of the playing field. So, first, MiniTest or Test::Unit? I just realized that 1.9.1 defaults to MiniTest no...

Listing subclasses doesn't work in Ruby script/console?

This works: >> class Foo >> def xyz() >> Foo.subclasses >> end >> end => nil >> class Bar < Foo >> end => nil >> class Quux < Bar >> end => nil >> Foo.new.xyz() => ["Quux", "Bar"] But this doesn't. User is a class in my application. >> User.subclasses NoMethodError: protected method `subclasses' called for #<Class:0x20b5188>...

Which CouchDB adapter for Ruby should I use?

Some of the options I've found are ActiveCouch CouchREST Couch Potato RelaxDB couch_foo I prefer projects that are on GitHub, since that makes it easiest for me to fork and push fixes. All of those fit that requirement. I'm used to Rails, so I like things that act like ActiveRecord models. On the other hand, I also don't want too ...

Submitting POST data from the controller in rails to another website

In the web app I'm building with ruby on rails I have a form that the user submits with some basic data. The data is retrieved in the controller and more information that needs to remain private is added. Then I need to send a post request to an external website with all of the combined data from the controller. What is the best way to...

localhost on rails

hi, I am sending an email that contains a link to my website. I want to be able to test it locally and be able to move the scripts around to different hosts easily. In my email right now I use the following: <%= url_for(:host => 'localhost:3000', :controller => "user_activations", :action => "show", :id=>@id, :confirm=>@passcode) %> ...

Rails ActiveRecord BigNum to JSON

Hi, I am serializing an ActiveRecord model in rails 2.3.2 to_json and have noticed that BigNum values are serialized to JSON without quotes, however, javascript uses 64 bits to represent large numbers and only ~52(?) of those bits are available for the integer part, the rest are for the exponent. So my 17 digit numbers become rounded o...