ruby-on-rails

Why does nginx + memcache corrupt my response body?

I'm caching some web pages in memcache. When I read the page directly from the cache, the page is well formed like this ... !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"-:-- 0 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> ...

ERD generator tool for Rails 2.3.2

SA I want and ERD Generator that understands the relations between Rails Models. I found Railroad but did not work with 2.3.2 I found also http://rails-erd.rubyforge.org/ but it is for Rails 3 Any idea? ...

Rails gem - geoipcity is not being included in the application

Hi, I installed the geoip_city gem, and i tested the gem in irb... Now when I am using the gem in the application I get an error uninitialized constant ApplicationController::GeoIPCity I guessed it is because I did not add the line require geoip_city So I tried adding the line to the function I used the code in, but then I got the er...

ActiveRecord select a string field has a certain length in Rails 3?

I've got a series of Posts and would like to select all posts where its title size is lesser than 30, how to do that? Posts.where("len(title) < 30")? ...

facebook social plugins and http basic auhtentication rails app

My app is in alpha stage and I have http basic authentication set up (in app controller) to restrict access my hosted app. Would the callback url work with http basic authentication? ...

With rails, how do I find objects NOT in a Has Many Through collection?

Let's say an article has many tags through taggings. Article has_many :taggings has_many :tags, :though :taggings end @article.tags #gives all the tags for that article How do I find all the tags that this article does NOT have? Thanks ...

Find all records that have a non-nil field?

I am trying to define two variables as follows: @orders = Customers.find_all_by_order_date(nil) @nonorders = Customers.find_all_by_order_date(!nil) The first works properly but the second doesn't. How can I find those customers whose order_date fields are not nil? @nonorders = @customer.orders.find(:all, :conditions => "@customer....

[Rails] Paginate throws error for Custom Validations

I'm attempting to create a custom validation for one of my models in Rails 2.3.5, but I keep recieving the following error everytime I run my testing suite: `method_missing_without_paginate': undefined local variable or method `validates_progression' app/models/project.rb class Project < ActiveRecord::Base ... validates_progres...

Can I send instance variables to Tequila (.jazz) JSON Parser? (Ruby on Rails)

I am using the great Tequila-JSON Parser ( http://github.com/inem/tequila ) in an Web-application, to render more or less complex JSON server-replies. More and more the JSON-Templates (.jazz) are growing in somehow real "views". I am trying now, to get an instance-variable from the according controller, into the .jazz template, but this ...

Index Multiple Columns w/ Ruby on Rails

I have a table in a Mysql db that I want to use multicolumn indexing on. How can I do this in rails w/o using the mysql console? ...

Modifying Rails helpers to add HTML classes

I'm starting to use the jQuery UI CSS Framework for an app, which means I have to start adding classes to everything. So, for example, I want to make all buttons jQuery-themed, which means adding a class to all buttons. I imagine there's some way in Rails to modify the helpers so I don't have to manually add a :class => 'blah' to every ...

What's the Rails way to mirror an LDAP directory as a SQL table?

So I'm creating a Rails app that will function as a directory for contact information in our organization. But it's not as simple as it sounds. We have a large LDAP-enabled directory which contains information for all of the users in our organization of tens of thousands. We have a smaller, separate LDAP-enabled directory which contain...

capistrano deploy_symlink fails

This is my first deployment. I did a cap deploy:setup which worked fine. Then, when I try to execute cap deploy:update I run into error messages. Something along the lines of rm: cannot remove `/var/www/app_name/current': Is a directory Here is my capfile and directory permissions. http://pastie.org/1189919 In general, what is the...

Rails: setting up has_many_through association between tables from different databases

I am trying to setup a has_many :through relationship between two models User and CustomerAccount through another join model AccountOwnership (users and account_ownerships tables are in one db, say db1 and the customer_accounts table is in remote db, say db2). Here is the relevant code, that sets up the associations class User < Activ...

what is the right way to model status values as an association in Rails?

I have a model called Contacts. Contacts can have different status "bad, positive, wrong..." These status may need to be changed over time, but across all contacts, they are the same options. Should I model it this way: Contacts.rb belongs_to :status_contact StatusContacts.rb has_many :contacts Then I manually populate the types ...

ActiveRecord: Doesnt call after_initialize when method name is passed as a symbol

I noticed that Rails doesn't trigger after_initialize callback when the callback symbol is passed as input. The code below doesn't work. class User < ActiveRecord::Base after_initialize :init_data def init_data puts "In init_data" end end The code below works. class User < ActiveRecord::Base def after_initialize ...

Rspec, Spork, & Autotest Error

I'm trying to teach myself rails by going through http://railstutorial.org/. I quit working on the tutorial app last night and then came back to it today. Now I'm getting an error when I start up the Spork server. Here is a trace of the error. spork Using RSpec Loading Spork.prefork block... can't convert nil into Hash (TypeError) /usr/...

How can I dynamically add a select element to a form using Prototype & Rails?

I have generated the code for a select & its objects using Rails: var insert_tag = '<select class="select medium" id="category_id" name="search[category_id]"><option value="-1">Select Category</option> <option value="1">Boats and Cruisers</option> <option value="2">Car Parts and Spares</option> <option value="3">Caravans</option> <optio...

Rails 3 Observer -- looking to learn how to implement an Observer for multiple models.

Hello, I'd like to add an Auditor Observer which does an action anytime after_create for 3 models (books, characters, authors)... I recently heard of the Observer capability but can't find any documentation on the ability. Is it support in Rails 3? How do I create an Auditor Observer that does something after_create for 3 models? Than...

http json post and rails polymorphic association

I want to update two table of my database with a http post request (JSON format) from my android app. my models look like this: class Ecg < ActiveRecord::Base has_one :record, :as => :payload end class Record < ActiveRecord::Base belongs_to :payload , :polymorphic => true belongs_to :user end an my record cotroller look...