ruby-on-rails

Rails on Windows: Slow?

I am doing some initial testing for a Rails app which will be deployed on Windows, but the development server in a VirtualBox is painfully slow. I've never seen anything like this in Linux (but the server platform must be Windows), even in an identical virtual appliance. Is Rails on Windows viable in terms of speed? ...

stubbing delegates

I stubbed the subset billed? method subset.stub(:billed?).and_return(true) line_item has a delegate for billed? to subset billed? when I call the methods the following occurs (rdb:1) subset.billed? true (rdb:1) subset.line_items[0].billed? false (rdb:1) subset === subset.line_items[0].order_subset true (rdb:1) subset.bill...

"undefined method" when calling helper method from controller in Rails

Does anyone know why I get undefined method `my_method' for #<MyController:0x1043a7410> when I call my_method("string") from within my ApplicationController subclass? My controller looks like class MyController < ApplicationController def show @value = my_method(params[:string]) end end and my helper module ApplicationHelp...

Why isn't the composite_primary_keys gem for Rails working?

I've followed the instructions here, installing the composite_primary_keys gem via sudo gem install composite_primary_keys That worked fine. Now when I add the following to my model set_primary_keys :user_id, :group_id and I get undefined method `set_primary_keys' for #<Class:0x1043bfe20> Also, using multiple primary keys in a m...

Why am I getting an error when requiring this gem in environment.rb?

I followed the steps here and installed the composite_primary_keys gem. When I try to require the gem in environment.rb at the very bottom of the file (after 'end') via require 'composite_primary_keys' I get this when starting the server "69125" => Booting Mongrel => Rails 2.3.4 application starting on http://127.0.0.1:3002 /Library/...

How to create Rails models with multiple complex associations/joins?

I am trying to figure out how to create ActiveRecord models with associations that can yield the same results as this SQL query: SELECT login, first_name, last_name, email_address FROM accounts INNER JOIN people ON person.id = accounts.person_id INNER JOIN email_address_people ON person.id = email_address_people.person_id INNER JOIN ...

Does a Rails 3.0.0.beta app only see bundled gems in the console?

I have a library that I'm trying to get working with rails 3 (specifically feedzirra) which I can require ok in irb but it breaks the console in my app with the following error: http://pastie.org/855976 ...

ruby-on-rails: Seeding-data strategies (or loading test data into developer database)

I want to clear and re-load my developer database (Ruby on rails) frequently. Of course, I can manually add the data via the web page but I was wondering if anyone has any strategies for this type of testing. (I already have unit, functional and integration tests, fyi) Thanks ...

How to send emails with return-receipts in Ruby on Rails?

Hi everybody, I have to send automatic emails with Return Receipt (aka "acknowledgement of receipt"), to have the confirmation that the receiver have actually received and read the email. The confirmation is a simple email sent to a specified address (the "Disposition-Notification-To" address, given in the email header). Do you know if...

Slow SSL Connection on SSL + LDAP

Hi guys, I have installed Ruby on Rails and am using Webbrick server. My Apache Server re-routes from port 80 to port 443 to have a SSL connection and LDAP. After the LDAP Authentication, MY SSL Page loads very slowly, sometimes, it just dosent load at all, sometimes blank page instead of project home page. IF I cancell the redirect...

Associate new Authlogic Model to existing Models

Hello, While playing around with Rails (since I am a newbie) while reading Agile Rails book I came across an issue using the Gem Authlogic that I don't know how to address. I have a simple business Model. The tables store the following information: Name, Address, Latitude, and Longitude. The above approach has been working fine, beca...

Rails where is en.yml

Where can Ifind the default em.yml file. I know for translated files on GitHub but I would like to have EN version. Thx. ...

Ruby on Rails: Nested named scopes

Is there any way to nest named scopes inside of each other from different models? Example: class Company has_many :employees named_scope :with_employees, :include => :employees end class Employee belongs_to :company belongs_to :spouse named_scope :with_spouse, :include => :spouse end class Spouse has_one :employee end Is ...

Resize an image with Paperclip [Rails]

The Paperclip plugin for Rails has a resize option that keeps the image in proportion. According to Ryan Bates' Paperclip Railscast, to make sure that option is on, you have to add a greater-than sign in the end of the size for the style you're looking to resize, as such: :styles => { :small => "160x160>" } I'm looking for Paperclip t...

Ruby on Rails: :include on a polymorphic association with submodels

When working with a polymorphic association, is it possible to run an include on submodels that are only present in some types? Example: class Container belongs_to :contents, :polymorphic => true end class Food has_one :container belongs_to :expiration end class Things has_one :container end In the view I'm going to want to d...

Skip before_filter in Rails

Names and objects have been simplified for clarity's sake. The basic concept reamins the same. I have three controllers: dog, cat, and horse. These controllers all inherit from the controller animal. In the controller animal, I have a before filter that authenticates a user as such: before_filter :authenticate def authenticate authe...

Export nested entities to CSV file

I have a rails app with some nested data that I'd like to export as a CSV file The models look like: class ContainerRecord < ActiveRecord::Base has_many :child_records and class ChildRecord < ActiveRecord::Base belongs_to :container_record I'd like to be able to export a CSV file with each ContainerRecord on a row with i...

Requiring authentication file from lib with cucumber

I am trying out Cucumber for the first time and I've come accross an issue. I am try to use RyanB's nifty authentication generator, but it seems I can't use the helper methods when running my Cucumber features. Part of my feature giving me problems: when I am on the new book page # features/step_defin...

Could i configure ultrasphinx relevance tiebreaker criteria?

Im using Ultrasphinx as a search engine for my site, we are using it with relevance sort-mode, so when it finds two results with same relevance, what is the tiebreaker? I want to be able to configure this tiebreaker criteria. Francisco ...

Can a database index span tables? I'm on Postgres

Is it possible to create an index that has as one of its columns values from another table? Example: model Pet primary_key id foreign_key Species end model Species primary_key id int genus end Assume there's a lot of kinds of species, with fewer types of genuses. I'd like to create an index on the Pets table by Genus. Can i...