ruby

Extracting email addresses in an html block in ruby/rails

I am creating a parser that wards off against spamming and harvesting of emails from a block of text that comes from tinyMCE (so it may or may not have html tags in it) I've tried regexes and so far this has been successful: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i problem is, i need to ignore all email addresses with mailto hre...

rake db:migrate fails when trying to do inserts

I'm trying to get a database populate so I can begin working on a project. This project is already built and I'm being brought in to help with front-end work. Problem is I can't get rake db:migrate to do any inserts. Every time I run rake db:migrate I get this: == 20081220084043 CreateTimeDimension: migrating ========================...

How do I serve a binary file through rack?

I think I'm being a bit silly here, but I keep getting errors complaining about the SERVER_NAME key missing from the env hash, and I can't find any substantial documentation on Rack::SendFile.. so- how do I serve up files? ...

Capistrano error while deploying to slicehost

Hi, im trying to deploy an application in slicehost using capistrano. I can log in via SSH using the same credentials, however when I try to deploy it i get the following error: executing `deploy' executing `deploy:update' ** transaction: start executing `deploy:update_code' updating the cached checkout on all servers executing locally...

ActiveRecord/sqlite3 column type lost in table view?

I have the following ActiveRecord testcase that mimics my problem. I have a People table with one attribute being a date. I create a view over that table adding one column which is just that date plus 20 minutes: #!/usr/bin/env ruby %w|pp rubygems active_record irb active_support date|.each {|lib| require lib} ActiveRecord::Base.estab...

Rails 2.3.5 table populated by fixtures at end of test run rather than at start

I start with a test database containing the schema but with no data in the tables. I run a test like so cd test/ ruby unit/directive_test.rb I get failures indicating that the code found no data in the data tables. However, I look at the tables after running that test and the data is now in the the table. In fact, if I immediately ru...

Rubycas-server and facebook

Hi. I'm using rubycas-server and noticed it supports Google authentication through the ClientLogin api. That basically allows me to send the users google account username and password and receive a reply stating true or false. Does Facebook have similar support in its API? I don't want to have to send the user through the Facebook con...

How to disconnect an existing ruby sequel connection to a database?

I mean the one which was previously established as DB = Sequel.sqlite('my_blog.db') or DB = Sequel.connect('postgres://user:password@localhost/my_db') or DB = Sequel.postgres('my_db', :user => 'user', :password => 'password', :host => 'localhost') or etcetera. The Sequel::Database class has no public instance method called "dis...

Ruby - Escape Parenthesis

I can't for the life of me figure this out, even though it should be very simple. How can I replace all occurrences of "(" and ")" on a string with "\(" and "\)"? Nothing seems to work: "foo ( bar ) foo".gsub("(", "\(") # => "foo ( bar ) foo" "foo ( bar ) foo".gsub("(", "\\(") # => "foo \\( bar ) foo" Any idea? ...

Copying a IO stream results in corruption.

I have a small Mongrel webserver that sends the stdout of a process to a http response: response.start(200) do |head,out| head["Content-Type"] = "text/html" status = POpen4::popen4(command) do |stdout, stderr, stdin, pid| stdin.close() FileUtils.copy_stream(stdout, out) FileUtils.copy_stream(stderr, out) puts "Sent r...

Using MongoDB with Ruby On Rails and the Mongomapper plugin

Hello, i am currently trying to learn Ruby On Rails as i am a long-time PHP developer so i am building my own community like page. I have came pritty far and have made the user models and suchs using MySQL. But then i heard of MongoDB and looked in to it a little bit more and i find it kinda nice. So i have set it up and i am using mong...

Ruby on Rails 2.3.5: update_all failing on ActiveRecord

I'm trying to update a collection of records in my database using ActiveRecord's update_all. Enter script/console. MyModel.update_all("reserved = 1", :order => 'rand()', :limit => 1000) ActiveRecord thinks order is a column, says it's unknown and throws an exception. According to the documentation though, my syntax looks sane. This is...

feedback for programming newbies looking to build a social networking site?

my partner and i are launching a social learning platform - the requirements have been mapped out and are quite basic/intuitive. we are familiar with html/css, and have some very basic understanding of php, but we would love some feedback on whether we should tackle this ourselves or not. we've built websites, but in the past relied mo...

How can I perform a two-legged oauth to use YQL with the ruby oauth gem?

I'm trying to perform a two-legged oauth in ruby to use YQL. There is an example in javascript which does what I want: http://paul.donnelly.org/demos/oauth.htm However, the ruby oauth gem API is different, and I can't figure out how to make the request. Any ideas? ...

Rendering a variable with erb.

I've got the following problem: I have rhtml (html minced together with ruby inside <% %> and <%= %> tags) stored in a database which I want to render. The information is acquired through a query. I need to be able to evaluate the information I get from the database as though as it was normal content inside the .erb-file. What I currentl...

Should I Use Anchor, Button Or Form Submit For "Follow" Feature In Rails

I am developing an application in Rails 3 using a nosql database. I am trying to add a "Follow" feature similar to twitter or github. In terms of markup, I have determined that there are three ways to do this. 1) Use a regular anchor. (Github Uses This Method) <a href="/users/follow?target=Joe">Follow</a> 2) Use a button. (Twitte...

simple regex to splice out text in ruby

I'm using ruby and I want to splice out a piece of a string that matches a regex (I think this is relatively easy, but I'm having difficulty) I have several thousand strings that look like this (to varying degrees) my_string = "adfa <b>weru</b> orua fklajdfqwieru ofaslkdfj alrjeowur woer woeriuwe <img src=\"/images/abcde_111-222-333/1...

checking current selection or value in a dropdown list using selenium

HI i was wondering if there is a way to check what is the current selected value in a drop down list using selenium ruby? thanks ...

Ending a Rails 2 URL with an IP address causes routing error?

I'm trying to construct URLs in the format http://servername/find/by/CRITERION/VALUE CRITERION is a finite set of strings, as is VALUE. Trouble is, VALUE needs to be an IP address in some situations, and it's causing me a routing error. Here's my route: map.find 'find/by/:criterion/:query', :controller => "find", :action => "by" ...

rspec mocking object property assignment

I have a rspec mocked object, a value is assign to is property. I am struggleing to have that expectation met in my rspec test. Just wondering what the sytax is? The code: def create @new_campaign = AdCampaign.new(params[:new_campaign]) @new_campaign.creationDate = "#{Time.now.year}/#{Time.now.mon}/#{Time.now.day}" if @new_campaign.save...