ruby

Do I need to close my connections to Amazon S3 in my Rails App?

I'm migrating my rails app to Heroku and need to change my file upload functionality to use Amazon S3 instead of local storage. I am using the aws-s3 gem and have this working but just want to make sure that I'm doing things right and not creating problems for myself. In my uploading code I have the following; AWS::S3::Base.establish_c...

Faulty ruby compilation with rvm: getting 'undefined symbol: rb_Digest_MD5_Init' while running racku

I am on Ubuntu. Any ideas? Do I have to set any compilation option? ...

ruby httparty get response url or id after post

How can I get the response url or id from a rails project with httparty in a separate script after doing a post? ruby script: HTTParty.post('http://localhost:3000/change_logs', parameters) response.body and all the others ones do not show the url and the response id ...

In ruby, what is the vertical lines?

1.upto(9) { |x| print x } Why won't { print x |x} } work? What about y? ...

How to use Tortoisesvn library ?

Hello everyone, I can't get diff from the subversion because it recognize the file that I'm commited is a binary file, so i need to use some functions in Tortoisesvn's library to compare. But I don't know how to use it :( . Please help! thanks :D ...

Cucumber prevent from clearing database

Hello, due to a heavy growing project I'm running into the trouble that the database rebuild process of cucumber really takes a long time. Since it is a application where the actual content of the table doesn't matter, I'd like to skip the rebuild process. Unfortunately wether cucumber nor database_cleaner seem to support this, doesn'...

How do you do a python "for-each" in Ruby?

foo = [3, 6, 3] for a in foo: print a How do I do that in ruby? ...

Where I can learn Cucumber in detail?

I am new on Ruby on Rails testing. I have seen many testing tools, such as Rspec,Cucumber,Seleneium,Watier etc. but could not detail information about that. Please give me a link for this. ...

Ruby Soap XML-RPC call very slow !

Hi everybody, I am using the Soap RPC lib to connect 1 client to 1 server (in different PC on the same network) in the server: require "soap/rpc/standaloneServer" ... class SyncServer < SOAP::RPC::StandaloneServer def initialize(*args) super add_method(self, 'remote_method') end end in the client: driver = SOAP::RPC:...

Sinatra PUT method not working?

For some reason, my "PUT" method isn't caught by Sinatra using this html. Can someone help me spot the mistake? When I use a "post" action in my controller, it works just the way it is expected... <form method="post" action="/proposals/<%[email protected]%>/addItem"> <input type="hidden" name="_method" value="put"/> <div> <label for="it...

markaby: using variable as class id

I am using markaby for the first time and would like to use a variable as a class id. Something along the lines of ... mab = Markaby::Builder.new val = 1 id_name = "this_id-#{val}" mab.p.id_name!, "Hello world" This, of course, yields <p id=name>Hello world</p> and what I am hoping for is <p id=this_id-1>Hello world</p> How doe...

How do I join by new line

I am reading a file which has source code. I need to append 2 spaces before each line. This is what I am doing. data = read_file data.split(/\n/).collect {|l| ' ' + l}.join('\n') However after joining when I do puts then it prints \n literally and it is not a line break. How do I fix that? ...

Ruby programming assignment

So i need some support with my Ruby assignment, I'm not from US so you have to excuse my English. We are building a hotel and this is the second assignment. It's a console based application and I have a class called main.rb that handles the runtime and a guest-class. In this second assignment we are to preload the app with five guest-...

Using ActiveRecord models in a gem - how to handle database config

I have several active record models in a rails app and I would like to extract these models into a gem so that I can easily use them in several web apps. The process seems pretty straight forward, except for passing along the configuration for the models. Do I: Add the configuration yaml file to the gem, thus assuring the databases wil...

Rails3: combine scope with OR

Hi, I need to combine name scope with or operator... Something like: class Product < ActiveRecord::Base belongs_to :client scope :name_a, where("products.name = 'a'") scope :client_b, joins(:client).where("clients.name = 'b'") scope :name_a_or_b, name_a.or(client_b) end Thx ...

Can sunspot-solr filter_by nested attributes?

Let's say I have People, and People has_many Watermelon . I have a filter_by that can work for People attributes, for example : :filter_by => 'has_eaten_today' But can I do a :filter_by for the nested attribute of Watermelon? For example : :filter_by => 'watermelons.created_at' Thanks! ...

Undefined method `+@' for false:FalseClass (NoMethodError) ruby

def next_prime_number (last_known_prime) while true last_known_prime++ found_factor = false # ERROR for i in 1...last_known_prime if last_known_prime % i == 0 found_factor = true break end end if !found_factor puts "new prime: #{last_known_prime}" Kernel.exit end end en...

struggling with conditional regular expressions

I have a simple problem, yet i am unable to solve this. Either my string has a format ID: dddd, with the following regular expression: /^ID: ([a-z0-9]*)$/ or as follows: ID: 1234 Status: 232, so with the following regular expression: /^ID: ([a-z0-9]*) Status: ([a-z0-9]*)$/ Now i want to make one regular expression that can handle b...

unexpected regex match

Hi, Can anyone explain why the following test is not passing. The regex is getting a match where I do not want one. I want to find a match on text that begins with Tel, Fax or Web but for some reason, the url in the test is getting a match: def test_url_should_match assert_no_match(/^[tel|fax|web]/i, "www.jehall.co.uk") end ...

Read database.yml from inside ActiveRecord migration

How do I access the contents of database.yml inside an ActiveRecord migration? Specifically, I need the value of the database key for the database being migrated. ...