ruby-on-rails

Class reloading stops after uncaught exception in custom middleware

I've written my own middleware to provide an API endpoint to our application. The middleware loads classes that provide the API methods, and routes the request to the appropriate class/method. The classes are loaded dynamically through String#constantize. While running in development mode, the classes are automatically reloaded. However...

Rails BST timezone implementation

Does anyone know how i can use BST for config.time_zone in my rails config/environment.rb file? At the moment i have left it as UTC and i'm thinking of adding BST to the list of supported timezones, and then extending the Time class to respect this (> last sunday of X month + 1hr) Where can i find the list of supported timezones? Sear...

Preventing delayed_job background jobs from consuming too much CPU on a single server

My Rails application has a number of tasks which are offloaded into background processes, such as image resizing and uploading to S3. I'm using delayed_job to manage these processes. These processes, particularly thumbnailing PDFs (using Ghostscript) and resizing images (using ImageMagick), are CPU intensive and often consume 100% CPU ...

Rails session_id in URL

I am trying to pass a session_id in a URL with Rails (2.3.1). The passing of the id is working through default_url_options, I am using memcache as a session store and I've set :cookie_only to false in environment.rb However it still does not seem to work. If I log in successfully, the first page is shown correctly, however when I contin...

ruby soap datatime adds Z at the end

Hi I have some strange behavior with ruby. In a rake file I pass in a date to soap method. In the response it appends a Z at the end of the date. in a lib file, same thing, same requirements, it doesn't. I need the case where it doesn't. It executes the same. What could it be? <n1:startDate>2009-08-18T00:00:00-05:00Z</n1:st...

Expiring a Rails Page cache automatically after a certain amount of time

I am generating a big sitemap for a site and using page caching on it, so that a sitemap.xml is generated in my public folder. Is there a way to have this page expire after say 3.days? I've looked but couldn't find anything that could do that. ...

using an aggregate function to narrow my query

I want to do something like this: SELECT locations.id, places.id, scannables.id, SUM(scannables.available) FROM `scannables` INNER JOIN places ON scannables.place_id = places.id INNER JOIN locations ON places.location_id = locations.id WHERE locations.id = 2474 AND scannables.bookdate BETWEEN '2009-08-27' and date_add('2009-08-27', IN...

'Stack level too deep' error in engine-like plugin with globalize

Hello folks. I have built an engine-like plugin thanks to the new features of Rails 2.3. It's a 'Product' module for a CMS, extrapolated from a previously existing (and working) model/controller. The plugin relies on easy_fckeditor and on globalize (description and title field are localised), and I suspect that globalized could be the cu...

Average from a Ruby Array

How would get find an average from an array? Say [0,4,8,2,5,0,2,6] would give 3.375 Thanks! ...

I cannot use passenger for my ruby on rails application on dreamhost.

I want to do some programming in ruby on rails on my Dreamhost server, so I connected via ssh and created a small application. Then I started the server and it worked. The problem is, that after some time the server kills itself. So I tried to activate Passenger in the user panel (which also has the advantage, that I don't have to connec...

Releasedate for Rails 3

Does anybody know when Rails 3 will be released? Tried to find info on the net - but nothing useful that I found... ...

Why is Array.count available in dev mode but not production?

For a recent project, I had a couple views with code like this: <% if @users.count == 0 %> This worked perfectly in development mode... I rolled it out to prod mode and it exploded, saying that count was not a valid method of Array. I changed every instance to use Array#length instead and it seems to be working. 1) What is the reason...

How to skip ActiveRecord callbacks?

I have model like this class Vote < ActiveRecord::Base after_save :add_points_to_user ..... end Is it possible to somehow force model to skip calling add_points_to_user when saved? Possibly something like ActiveRecord#delete vs ActiveRecord#destroy? ...

Load Binary Data From a File via ActiveRecord Create

Is there an easy (or generally accepted) way to load up a binary column using the create method of ActiveRecord? For example, what I'm trying to do is something similar to this: MyTableObject.create :name => "Test", :image => File.read("PathToMyFile.jpg") ...

How to change the IdType in item_lookup from ASIN to ISBN, amazon-ecs for Ruby

That's my whole question! Doing something like this: Amazon::Ecs.item_lookup('9781934356166', :response_group => 'ItemAttributes,Images') Not sure where to change the option for the IdType to ISBN. I've tried putting it several places. Thanks! ...

Ruby on rails connection problem

I have a Ruby on Rails project that I was developing on a hosted server but have decided to work on my local windows machine with. To get started I thought I'd make sure that I could just take my models from the old project and put them in a new project then query them in the console. This fails. Edit to reflect more accurate problem:...

(Rails, Flash) Why would my updated Flash chart not be refreshing in Internet Explorer?

Hi All, I've got a bit of an odd issue here. Basically it only occurs in IE. Safari, Firefox, and Opera work just fine. FYI, I am using XMLCharts (http://www.maani.us/xml%5Fcharts/) to display chart data. Basically I have a library that generates up-to-the-minute data on the fly based on selected date ranges. Well, for whatever rea...

Problem with generator script -- uninitialized constant Rails::Generator::Commands::Base::ActiveRecord)

I have an issue with my generator script. Here is the command I am using: ruby script/generate migration add_stuff And here is the error I am getting: uninitialized constant Rails::Generator::Commands::Base::ActiveRecord I have tried updating my system, as well as installing/uninstalling my rails application. I am working on Windo...

How can I see the SQL that will be generated by a given ActiveRecord query in Ruby on Rails

I would like to see the SQL statement that a given ActiveRecord Query will generate. I recognize I can get this information from the log after the query has been issued, but I'm wondering if there is a method that can be called on and ActiveRecord Query. For example: SampleModel.find(:all, :select => "DISTINCT(*)", :conditions => ["`d...

Site wide search on a rails application

Hi, I'm trying to add search capability to one of my rails applications. I just need it to search through the mysql columns of quite a few models well. I'm wondering what the best way to do this is. I figure I should use a plugin but I don't see anyone really recommending one over another. Is there one you would recommend over all ot...