ruby-on-rails

awesome_nested_set

I have a select input: f.select :category_id, nested_set_options(Category, @categories) {|i| "#{'-' * i.level} #{i.name}" } What is the most efficient way to show only the categories with level > 1 ? ...

ruby handsoap documentation

Hi, Does anybody know some nice documentation about the ruby "handsoap" gem to get me started? Thanks ...

how do i initialize the money gem?

I have a new gem I'm playing with, but I'm not sure where to put it so that it is initialized, but that I don't have to do it each and every time I use my method which uses it. def self.get_rate(from, to, amount) Money.default_bank.fetch_rates #<---------------- Here it is... if to == "USD" or from == "USD" rate = Mon...

Ruby, Rack and headers such as "Accept-Ranges" or "X-Content-Duration"

Does anyone have an example of how to add additional headers to the Thin Ruby server? Specifically, I need to add either "Accept-Ranges" or "X-Content-Duration" for media based files served, ogg audio and video mostly, served via the new HTML5 media elements. If someone has a fix for this, or a link to a really good tutorial about Rack,...

How to validate selects / inserts are hitting the right server with MySQL Master/Slave

I've got a rails app using the master_slave_adapter plugin (http://github.com/mauricio/master_slave_adapter/tree/master) to send all selects to a slave, and all other statements to the master. Replication is setup using Mysql master / slave. I'm trying to validate that all the SQL statements are indeed going to the right place. Select...

Inserting an invalid ActiveRecord date to a MySQL database

MySQL allows the value of "0000-00-00" for date fields, however ActiveRecords treats an assignment to a Date value with that string as being nil. I have a legacy application that relies on that exact field content for the notion of "Never", so if the customer last payment date is "0000-00-00" it acknowledges as being "Never" paid. Is t...

How to limit the resource formats in the Rails routes file

When routing resources in Rails the optional format attribute is automatically appended to the generated routes. This is so that the resource in question can be requested as either XML, HTML etc. Which formats that is actually allowed is usually described in the controller using respond_to. But in many cases you only want to support HTM...

How to find references when refactoring rails application with textmate?

I have been practicing TDD in C# for several years now and recently have moved to Ruby on Rails full time. I am continuing the practice of TDD with RSpec. My question is regarding the process of finding references while refactoring. In Visual Studio I was addicted to Resharper's "find all references" when renaming or replacing methods. ...

automatic rails app startup on server boot?

Hi, how can I make ruby on rails app start automatically on Mac OS X Server boot? Thanks. ...

rails rjs replacement and swap values

I'm trying to figure out how to use RJS to swap between two fields... i know how to replace the values but I can't seem to figure out how to read it. Is it not possible to read values thru RJS? Only to replace? <%= link_to_function "Swap" do |page| #to_value = page[:currency_to].value page[:currency_from].value = to_value...

Desktop Application Framework similar to Rails

I'm looking for a desktop application framework similar to Rails: Good ORM MVC Default directory structure View Helpers/DSL Elegant Open Source Fun language Decently mature ...

Session management in Rails (2.3)

Apparently, after upgrading to Rails 2.3 my session storage has stopped working. I used to have this: session :session_expires => 3.years.from_now in my application_controller.rb, but now every time i close the browser (chrome) the session expires. I read from somewhere that session_expires would have changed to expire_after, but sess...

Breaking up a Rails app into two

Hi All, We have a very lage Rails app that has two distinct sections: the front end and the CMS/Admin. We would like to break up the app into two pieces (for maintenance, as we have distinct teams that work on the front end vs. back end and they could have different release cycles). One thought was to start a new Admin 2.0 app that has...

How do you manage Ruby on Rails migrations with a team of developers?

We have a team of developers who are each going to be developing database migrations for our system using the Rails tools. Migrations seems at first like a great way to manage changes to the database schema, but as we go on it has become harder to manage changes in a distributed way. If we each develop migrations on our own, how can we r...

How do I set the location for the link in the title of a google reader subscription

I've got an atom feed in my application that's build using atom_feed, and it's working, except that when the feed is subscribed to in Google Reader, the link it uses for the title of the subscription is pointing to the wrong URL. I tried specifying the root_url parameter as such: atom_feed(:root_url => 'http://link.to/proper.page') do ...

Using delayed_job across multiple machines with some tasks that need to run locally

I'm trying to use delayed_job for various parts of a rails app. The problem is that if we have multiple instances of the app running, but certain jobs (processing uploads, for example) need to be run by local workers, whereas others could benefit by being run by any worker. Does anyone have any recommendations for a good approach to hav...

Postgresql causing "no space on device" error but disks/partitions are not full

I'm getting the following error while running my Rails website and I believe it is causing it to go down. I'm using Passenger and my site is heavily trafficked. When I try to bring it back online, Apache spawns a large number of children and the load on the machine spikes to about 50, and the site becomes extremely slow. I have no shor...

Rails Plugins

Is it possible to include view code in a plugin, such that an app using the plugin can simply call reference the view code like it might reference one of its own partials. Am I off track here or are there good examples of plugins which do this.. ...

How to Determine if Rails Association is Eager Loaded?

Does anyone know a way to determine if a Rails association has been eager loaded? My situation: I have a result set where sometimes one of the associations is eager loaded, and sometimes it isn't. If it isn't eager-loaded, then I want to look up associations using ActiveRecord's find. If it is eager loaded, I want to use detect. ...

Tempfile and Garbage Collection

I have this command in a Rails controller open(source) { |s| content = s.read } rss = RSS::Parser.parse(content, false) and it is resulting in temporary files that are filling up the (scarce) disk space. I have examined the problem to some extent and it turns out somewhere in the stack this happens: io = Tempfile.new('open-uri')...