ruby

Ruby on iPhone

Hi I'm looking into iPhone development, and objective-c is not be my preferred language. As far as I can see at this moment Ruby cannot be used to talk to Cocoa-touch at the moment on the iPhone. So my question is, am I wrong? Can I use Ruby on the iPhone to develop Cocoa-touch applications. And what is the future looking like for Ruby ...

Given an array of ActiveRecord objects, can I easily collect their relationships through a method call?

Let's say I have the following code: @sites = Site.find(session[:sites]) # will be an array of Site ids @languages = Language.for_sites(@sites) for_sites is a named_scope in the Language model that returns the languages associated with those sites, and languages are associated with sites using has_many through. The goal is for @langua...

How can I install local gem?

If I download a .gem file to a folder in my computer, can I install it later using gem install? ...

Single Table Inheritance find issues

I have the following 3 rails classes, which are all stored in one table, using rails' Single table inheritance. class Template < ActiveRecord::Base class ThingTemplate < Template class StockThingTemplate < ThingTemplate If I have a StockThingTemplate with ID of 150 then I should logically be able to do this: ThingTemplate.find(150) =...

Continuous Integration for Ruby on Rails?

I've been searching around for a Continuous Integration solution for Ruby on Rails, but haven't been too pleased with the results. I came from a .NET shop that used CruiseControl.NET and was really spoiled with it's ease of use and rich status/reporting. Ideally I'm looking for: The obvious Git/SVN and Test::Unit integration Integrat...

What code highlighting libs are there for Ruby?

What'd also interest me is which have more or less dependencies. ...

Standard File Naming Conventions in Ruby

For a file containing the given class, SomeCoolClass, what would be the proper or standard filename? 1. somecoolclass.rb 2. some_cool_class.rb 3. some-cool-class.rb 4. SomeCoolClass.rb or some other variation? I noticed in the Ruby stdlib, versions 1, 2 and 3 are used. ...

Ruby on Rails and jeditable (jquery)

Hi there, Has anyone gotten the jquery plugin jeditable to run properly in a Rails applications. If so, could you share some hints on how to set it up? I'm having some trouble with creating the "submit-url". Regards, Sebastian ...

How to display events in the calendar using Ruby?

I am building a calendaring application in ruby on rails. I am using my own schema for storing events, but I don't know how to display events in calendar, and also how to add a calendar in my application. Will I have to write code to display calendar or can I use any plugin to display calendar. ...

Composite keys with ActiveScaffold in Ruby On Rails

I am developing RoR application that works with legacy database and uses ActiveScaffold plugin for fancy CRUD interface. However one of the tables of my legacy db has composite primary key. I tried using Composite Keys plugin to handle it, but it seems to have conflicts with ACtiveScaffold: I get the following error: ActionView::Templa...

How can I write a hook that gets called when a RubyGem is installed?

I'd like to write a Ruby snippet that gets run when my Gem is first installed via [sudo ]gem install mygem. Can it be done? ...

Rails ignoring render and redirect_to

Hi, I've got a really simple rails question here but I can't seem to find the answer anywhere. I guess some of the problems stem from me following a tutorial for Rails 1.2 with Rails 2.1. Anyway.. I'm writing a blog system and I'm implementing the comments bit. I have comments displaying fine once I've created them using script/console...

Using Ruby-based MySQL adaptor when the C MySQL gem is already installed?

Well this is incredibly frustrating. After being nagged by Rails that I need to install the C-based MySQL adaptor, I did so... and then discovered that it won't work with MySQL under version 6. Now 'gem uninstall mysql' results in 'unknown gem mysql'. I just spent half an hour trying to get the thing to install in the first place (...

Indexes for has_many :through

Suppose you have two models, User and City, joined by a third model CityPermission: class CityPermission < ActiveRecord::Base belongs_to :city belongs_to :user end class City < ActiveRecord::Base has_many :city_permissions has_many :users, :through => :city_permissions end class User < ActiveRecord::Base has_many :city_permi...

How much JavaScript do you let Rails generate?

Ruby on Rails has a lot of ways to generate JavaScript. Particularly when it comes to Ajax. Unfortunately, there are a few problems that I often see with the JavaScript that it generates. Rails typically uses inline event handling. <a onclick="somejavascript(); return false;" /> This is generally frowned upon, as it's mixing ...

Elegant structured text file parsing

I need to parse a transcript of a live chat conversation. My first thought on seeing the file was to throw regular expressions at the problem but I was wondering what other approaches people have used. I put elegant in the title as i've previously found that this type of task has a danger of getting hard to maintain just relying on reg...

How do you make a method apply to a collection of ActiveRecord objects.

Currently, if I want to apply a method to a group of ActiveRecord objects, I have to structure the call like so: messages = Message.find(:all) csv = Message.to_csv(messages) How can I define the method so it's structured like so? messages = Message.find(:all) csv = messages.to_csv This is the current model code: require 'fastercsv...

In Ruby on Rails, how do I make a polymorphic model associate to a namespaced model?

I have the following models. # app/models/domain/domain_object.rb class Domain::DomainObject < ActiveRecord::Base has_many :links_from, :class_name => "Link", :as => :from, :dependent => :destroy end # app/models/link.rb class Link < ActiveRecord::Base belongs_to :from, :polymorphic => true belongs_to :object_value, :polymorphic...

What does __FILE__ mean in Ruby?

I see this all the time in ruby: require File.dirname(__FILE__) + "/../../config/environment" What I am wondering is what does the __FILE__ mean? ...

Creating a Personal Project

Again I concede the great and wise S/O: I am thinking about putting together a personal project to help me learn Ruby better (!rails) and GUI programming. I am probably going to do MacRuby but could do wxRuby or something else as well. So I wanted to get some options on how to guys decide on personal projects. That aside, what are s...