ruby

fields_for, formtastic, ActiveMerchant, and validation errors

I'm trying to use Formtastic to create a payment form, since I'd like to use the inline errors. I'm using ActiveMerchant to handle the billing. I have the following form: <%= semantic_form_for @payment do %> <%= form.inputs do %> <%= form.input :email, :label => "Email Address" %> <%= form.semantic_fields_for :credit_card_at...

RoR: fields_for and partials.

hi, i am using nested_attributes for an association of products back to a transaction. I need to add a date to the products model. I would like to add a link to set the date_select to today. here is the view: <% f.fields_for :trans_products do |builder| %> <%= render 'trans_product_fields', :f => builder %> ...

S3::Error::NoSuchKey: The specified key does not exist.

Im getting this error when I try and make an object. Here is my routine: service = S3::Service.new( :access_key_id => S3_ACCESS_KEY, :secret_access_key => S3_SECRET ) puts "connection established with s3" puts "finding bucket" bucket = service.buckets.find("test") puts "building object" object = bucket.objects.build("jso...

Why does Ruby have both private and protected methods?

Before I read this article, I thought access control in Ruby worked like this: public - can be accessed by any object (e.g. Obj.new.public_method) protected - can only be accessed from within the object itself, as well as any subclasses private - same as protected, but the method doesn't exist in subclasses However, it appears that p...

Google Checkout Buy Now Buttons w/ Google Doc Forms

I have a Google Checkout account and have been using it to sign up for classes. I currently just use a Buy Now button but would like to grab more information about the user than simply an email address and credit card information. Is there a way to integrate Google Checkout Buy Now Buttons with Google Doc Forms? I'm trying to find a ...

S3::Error::SignatureDoesNotMatch: when I try and save a new object

this is coming up on my save, not when I try and sign in. Here is my code: service = S3::Service.new( :access_key_id => S3_ACCESS_KEY, :secret_access_key => S3_SECRET ) puts "connection established with s3" puts "finding bucket" bucket = service.buckets.find("") puts "building object" object = bucket.objects.build("#{RAIL...

ruby integer to boolean

Hello all, I have a DB field that is integer type and values are always 0 or 1. How do I grab the equivalent boolean value in ruby? such that when i do the following the check box is set appropriately: <%= check_box_tag 'resend', @system_config.resend %> ...

How can I run perl and ruby scripts as tasks in ant?

I would like to be able to run ruby and perl scripts from build.xml in ant. ...

framework and aprroach to get youtube insight data using ruby

Hi, I need to get user, channel & video insight data (views, ratings, subscribers etc) from youtube using ruby. which tool/gem/framework to use: I know this is asked before, but this is specific to my problem, I dont want to upload videos etc, most of the frameworks seem geared to this. None of these seem to be a great fit to me, am ...

Rails 3, Ruby 1.9.2 and acts_as_taggable_on not playing nicely

I'm rewriting my rails application to work with rails 3 and when I migrate the acts_as_taggable_on migration I get this error: == CreatePosts: migrating ==================================================== -- create_table(:posts) rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table ...

Date with ruby.

This is my date 20100816 and it integer date. I want to display it like 08/16/2010. What's the best way to do it? ...

calling methods dynamically inside a controller

Hi All, I have the following scenario I want to add methods dynamically to a controller. All my method names are in a table . Please refer the following example -table (method_names)- 1 - Walk 2 - Speek 3 - Run and I have a controller class UsersController < ApplicationController def index end end Inside this index act...

How do you update rubygems using rvm and ree?

How do you update rubygems under rvm when ree is your default vm (on Snow Leopard)? I am doing: $ rvm ree gem update --system This results in things looking like everything went fine: Updating RubyGems Updating rubygems-update Successfully installed rubygems-update-1.3.7 Updating RubyGems to 1.3.7 Installing RubyGems 1.3.7 RubyGems...

Can YAML entries be used a subsets of entries in same file?

I am using a YAML file for configuration in my rails app and a few entries in the file are subsets of future entries, eg - domain: domain.com name: jack email: [email protected] To make this more efficient, is something like this possible in YAML ? domain: domain.com name: jack email: jack@${domain} ...

Retrieving unique associated models from an array of another model

What is the recommended approach for finding multiple, unique associated models for a subset of another model? As an example, for a subset of users, determine unique artist models they have favorited. One approach is to grab the users from the database, then iterate them all quering for favorites and building a unique array, but this se...

What is a good way to do a light unit-testing in an Rails web application?

I am on a tight timeline with minimum resources for a project. I would like to practice test driven development for this project, but realistically, i would not have time to learn any of the more sophisticated frameworks like Cucumber, Rspec, etc. And it would probably be counter-productive at this point anyway What do you recommend i...

Rails: how to use conditions and only let the db look 100 records deep, I'm not looking for limit

I'm adding data to a db and I only need to check for duplicated data within the last 30 minuets or so. Data is getting added at about 10 entries per minuet so I only need search about 300 records. How can I get this in conditions with rails Model.find(:all, :conditions => [])? ...

Ruby matrix operation

I was trying to get familiarize myself with matrices in Ruby. I am trying to initialize a matrix with a input in string format. I tried the following code, but its not working. Please help me what I'm doing wrong. input = '08 02 22 97 49 49 99 40 81 49 31 73 52 70 95 23' x = Matrix.rows(input.lines() { |substr| substr.strip.spl...

Why am I getting "undefined method '+' for nil:NilClass" ?

isn't + an operator? why would it not be defined? here's my code: Class Song @@plays = 0 def initialize(name, artist, duration) @name = name @artist = artist @duration = duration @plays = 0 end attr_reader :name, :artist, :duration, attr_writer :name, :aritist, :duration def play @plays += 1 @@play...

Great Ruby tracing gem?

Read about this one: http://unroller.rubyforge.org/ http://github.com/TylerRick/unroller Look at the pictures! Unfortunately, it's very outdated and not actively maintained. I wonder, are there any other tools similar to this one that can show me what code was just executed, in what file, what the output was and what the return valu...