ruby-on-rails

Creating a multi-tenant application using PostgreSQL's schemas and Rails

Stuff I've already figured out I'm learning how to create a multi-tenant application in Rails that serves data from different schemas based on what domain or subdomain is used to view the application. I already have a few concerns answered: How can you get subdomain-fu to work with domains as well? Here's someone that asked the same ...

Recalculate Counter Cache of 120k Records [Rails / ActiveRecord]

The following situation: I have a poi model, which has many pictures (1:n). I want to recalculate the counter_cache column, because the values are inconsistent. I've tried to iterate within ruby over each record, but this takes much too long and quits sometimes with some "segmentation fault" bugs. So i wonder, if its possible to do th...

Rails 2.3.5 table populated by fixtures at end of test run rather than at start

I start with a test database containing the schema but with no data in the tables. I run a test like so cd test/ ruby unit/directive_test.rb I get failures indicating that the code found no data in the data tables. However, I look at the tables after running that test and the data is now in the the table. In fact, if I immediately ru...

Rails model relations depending on count of nested relations

I am putting together a messaging system for a rails app I am working on. I am building it in a similar fashion to facebook's system, so messages are grouped into threads, etc. My related models are: MsgThread - main container of a thread Message - each message/reply in thread Recipience - ties to user to define which users should sub...

Ruby - Escape Parenthesis

I can't for the life of me figure this out, even though it should be very simple. How can I replace all occurrences of "(" and ")" on a string with "\(" and "\)"? Nothing seems to work: "foo ( bar ) foo".gsub("(", "\(") # => "foo ( bar ) foo" "foo ( bar ) foo".gsub("(", "\\(") # => "foo \\( bar ) foo" Any idea? ...

how to specify the file path in rails over Mongrel web server

hi, I have a request to load a swf file, flaMovie.swf from rails. The swf file is located the directory /home/user1/railsproj/flash. I have the code index.rhtml under view directory to show the .swf file, ID=flaMovie WIDTH=250 HEIGHT=250> When I ran the code, I got the error, ActionController::RoutingError (No r...

Redmine with IronRuby (Windows)?

Has anyone tried to run Redmine using IronRuby? Is it possible? ...

Rails send mail with GMail

Hi Everyone, I am on rails 2.3.5 and have the latest Ruby installed and my application is running well, except, GMail emails. I am trying to setup my gmail imap connection which has worked previously but now doesnt want to know. This is my code: # Be sure to restart your server when you modify this file # Uncomment below to force R...

Using MongoDB with Ruby On Rails and the Mongomapper plugin

Hello, i am currently trying to learn Ruby On Rails as i am a long-time PHP developer so i am building my own community like page. I have came pritty far and have made the user models and suchs using MySQL. But then i heard of MongoDB and looked in to it a little bit more and i find it kinda nice. So i have set it up and i am using mong...

Using named_scopes on the join model of a has_many :through

Hi folks. I've been beating my head against the wall on something that on the surface should be very simple. Lets say I have the following simplified models: user.rb has_many :memberships has_many :groups, :through => :memberships membership.rb belongs_to :group belongs_to :user STATUS_CODES = {:admin => 1, :member => 2, :invi...

Implications of calling yield() twice

What are the implications of calling yield() twice? For example - if yield :content_header yield :content_header - else No Content Header Is this going to eat up little bits of time? I can't seem to get content_for? to work :/ ...

How do I quiet image_submit_tag from params hash?

Does anyone know how to eliminate the x and y params when you use image_submit_tag with a get method? I have a simple search form, and using get to pass the value in the url. When I use image_submit_tag, it also appends the x and y coords, so I get urls like http://example.com?q=somesearchterm&x=15&y=12 When I have used subm...

ruby on rails, searchlogic and refactoring

Hey all, I'mt not too familiar with searchlogic plugin for rails (I did view the railscasts but wasn't helpful in relation to the specific code below). Can anyone briefly describe how it is being used in the three methods below? Thanks for any response. def extract_order @order_by = if params[:order].present? field = params[:order]...

How to properly use ActiveResource::CustomMethods when constructing URL?

Currently I am using Active Resource to consume a REST API. It works fine for simple things but for some reason will not respect custom methods. E.G. API::Model.find(m.id) #This works as expected API::Model.find(m.id).put(:foo) #This is equivalent to doing the above The Rails API http://api.rubyonrails.org/classes/ActiveResource/Cu...

heroku mongohq and mongoid Mongo::ConnectionFailure

UPDATE 12th aug 2010: Although I got an accepted answer 6th may from Jackues Crocker, there are aspects of this issue that makes it easy to mess up! It happened to me yet again and I decided to research the mongoid source code. So, here it goes: Currently, host: port: name/database: settings TAKE PRECEDENCE OVER the uri: setting. Hence...

Change model name in rails easily

I'm going to need to change one of my model names. Is there anything out there that will replace every instance of the original model name in the controllers views and tests or do I have to do it all manually, page by page? ...

Ruby on Rails 2.3.5: update_all failing on ActiveRecord

I'm trying to update a collection of records in my database using ActiveRecord's update_all. Enter script/console. MyModel.update_all("reserved = 1", :order => 'rand()', :limit => 1000) ActiveRecord thinks order is a column, says it's unknown and throws an exception. According to the documentation though, my syntax looks sane. This is...

ruby on rails setup on my ubuntu

Do I need to set up virtual hosts as mentioned here: http://wiki.rubyonrails.org/deployment/apache-passenger I am just setting up dev env on my own machine to try and learn ruby on rails. thanks in advance. ...

Real time ruby apps: CRAMP vs NODE.JS

Hi folks, i was wondering if any of you had insights about which one is better, and what factors should be taken into consideration when using one of these ...

Rendering a variable with erb.

I've got the following problem: I have rhtml (html minced together with ruby inside <% %> and <%= %> tags) stored in a database which I want to render. The information is acquired through a query. I need to be able to evaluate the information I get from the database as though as it was normal content inside the .erb-file. What I currentl...