ruby

Trying to convert existing production database table columns from enum to VARCHAR (Rails)

Hi everyone, I have a problem that needs me to convert my existing live production (I've duplicated the schema on my local development box, don't worry :)) table column types from enums to a string. Background: Basically, a previous developer left my codebase in absolute shit, migration versions are extremely out of date, and apparen...

What exactly is Arel in Rails 3.0?

I understand that it is a replacement for ActiveRecord and that it uses objects instead of queries. But... why is this better? will objects/queries be "easier" to create? will it lead to more efficient SQL queries? will it be compatible with all major DBs? - I assume it will. will it be easier/harder to use with stored procedures...

Which ruby version/build works best with rails 3?

I've been having trouble discerning which version/build of ruby to use with the most recent rails 3 beta. I was using 1.8.7 but over time the server would use too much memory and begin to slow down and eventually not work at all. Which version/build worked best for you? ...

Association with Searchlogic

Hi I have a post model that :has_many :reply, when using searchlogic, doing Post.reply_content_like("search"), returns a result for every reply under that post, I only want it to return once. Anyone know a way to solve this ...

Ruby LESS gem equivalent in Python

The Ruby LESS gem looks awesome - and I am working on a Python/Pylons web project where it would be highly useful. CSS is, as someone we're all familiar with recently wrote about, clunky in some important ways. So I'd like to make it easier on myself. Is there an existing Python module or library that provides parallel functionality? ...

Unique view count.

I have a collection of links which are being displayed on the index page. Whenever a user clicks a link I want to keep a track of the number of unique views. I know it can be done by tracking the ips whenever a click happens by request.remote_ip and then the link of the page that was clicked. Is there any better approach ? Any plugins et...

Use ruby methods in javascript without ajax

Hi everyone! Is it possible to call a ruby method inside javascript? One way of implementing it is via ajax calls, but is there a way I can embed that ruby function inside the js file and call it just like calling any other js function? ...

Make FalseClass behave like TrueClass with meta programming

This is theoretical question: is it possible to change FalseClass behavior to act like TrueClass? It is possible to override to_s, xor, &, | behavior but that is not enough. If you like Test Driven Development, follow my colleague's suggestion: puts "false is new true!" if false puts "never happens" if true assert false Asserts won'...

Good books on Ruby based DSL

I'm trying to create a DSL in ruby, can you suggest me some good books? I looked around amazon and safari but so far couldn't find any. Thanks in advance! ...

Rails find all with association

I have what I think is a very simple problem (famous last words)... I have a Category model that has_and_belongs_to_many Events. I want to construct a simple and efficient query that finds all categories that have 1 or more events. (using Rails 3) I'm sure I'm having a dumb moment here - any help appreciated :) ...

Escape doube and single backslashes in a string in Ruby

Hello. I'm trying to access a network path in my ruby script on a windows platform in a format like this. \\servername\some windows share\folder 1\folder2\ Now If I try to use this as a path, it won't work. Single backslashes are not properly escaped for this script. path = "\\servername\some windows share\folder 1\folder2\" d = Dir...

Best way to add comments in erb

What is the best way to add comments in erb files, if we do not want them to be generated into the html content? ...

Aliasing a namespaced route in Rails

Hi all, Given the following routes.rb file: # Add Admin section routes map.namespace :admin do |admin| admin.resources :admin_users admin.resources :admin_user_sessions, :as => :sessions admin.resources :dashboard # Authentication Elements admin.login '/login', :controller => 'admin_user_sessions', :action => 'new' ...

xvfb on a machine with a display, can an application run 'in the background?'

I'm setting up to cron a web scraping job, using xvfb, firefox, and watir on my Mac OS X. In testing the script so far, firefox pops up visibly on the local desktop, the watir script executes, and then firefox exits (I quit firefox in my script). I'd like to set the xvfb DISPLAY such that firefox will run, but won't be seen on the loca...

Rails two-legged OAuth provider?

I have a rails 2.3.5 application with an API I wish to protect. There is no user - it is an app to app style webservice (more like an Amazon service than facebook), and so I would like to implement it using a two-legged OAuth approach. I have been trying to use the oauth-plugin server implementation as a start: http://github.com/pelle...

Nokogiri pull parser (Nokogiri::XML::Reader) issue with self closing tag

I have a huge XML(>400MB) containing products. Using a DOM parser is therefore excluded, so i tried to parse and process it using a pull parser. Below is a snippet from the each_product(&block) method where i iterate over the product list. Basically, using a stack, i transform each <product> ... </product> node into a hash and process ...

How to install Nokogiri as a Macruby gem?

The latest MacRuby release notes (v0.6) state that the authors have managed to get this release working with the SQLite and Nokogiri gems. However when I run sudo macgem install nokogiri I get the following errors: ERROR: Error installing nokogiri: extconf failed: and then a bunch of paths followed by: libxml2 is missing. try 'por...

like-vim emacs ruby indentation

ruby-mode from svn, looks equal to 1.1 version here is emacs indentation of hash User.all({ :joins => :account, :conditions => {:delete_at => nil} }) here is the same in vim User.all({ :joins => :account, :conditions => {:delete_at => nil} }) How to make emacs indent like vim in ruby-mode? ...

Limesurvey alternative for Ruby on Rails?

Does anyone know of a full featured survey tool for rails? Like Limesurvey (PHP -unfortunately for my purposes.)? Tried to look on Ruby-toolbox, but it seems to be down. ...

Using Cucumber or RSpec+Selenium to create end user documentation?

Has anyone tried creating end user (potentially online, potentially to be printed) help/documentation out of your cucumber scenarios? Or taken screenshots for use in documentation using RSpec and Selenium RC's ability to do so? For Cucumber, I'm imagining something like: Scenario: If you want to add a link Given I am on the edit blog p...