ruby-on-rails

From objects to tables using activerecord

Hi all, I'm getting some objects from an external library and I need to store those objects in a database. Is there a way to create the tables and relationships starting from the objects, or I have to dig into them and create migrations and models by hand? Thanks! Roberto ...

When would you NOT want to use memcached in a Ruby on Rails app?

Assuming a MySQL datastore, when would you NOT want to use memcached in a Ruby on Rails app? ...

Apache/Rails/Passenger Displaying Site Index?

I have a Rails app that I have successfully tested with Mongrel and Webkit. Now I want to test deployment. I set up a VMWare Image using Ubuntu 8.04. I have installed Rails following this method https://help.ubuntu.com/community/RubyOnRails with the exception of using Gems 1.3 instead of 1.2. I have configured and installed Passenger...

Connection error for sqlserver rake db:migrate

I am getting the following error: Open OLE error code:80004005 in Microsoft OLE DB Provider for SQL Server [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. HRESULT error code:0×80020009 Exception occurred. I have tried following the directions here with no luck: http://wiki.rubyonrails.org/rails/pag...

Capistrano not restarting Mongrel clusters properly

I have a cluster of three mongrels running under nginx, and I deploy the app using Capistrano 2.4.3. When I "cap deploy" when there is a running system, the behavior is: The app is deployed. The code is successfully updated. In the cap deploy output, there is this: executing "sudo -p 'sudo password: ' mongrel_rails cluster::restar...

Notification of object destruction in Ruby

I have written a custom Rails model. This model is backed by an actually server not by a database table (so it does not inherit from ActiveRecord::Base). In order to get the requested information from the server I open a SSH connection to it. Because rails does not reuse object a new object, as well as a new SSH connection to the serv...

Capistrano + thin + nginx with user not allowed to sudo howto?

I have a scenario like this which I want to use capistrano to deploy my ruby on rails application: The web application is on a thin cluster with the config file stored under /etc/thin. also an init script is in /etc/init.d/thin, so it would start automatically whenever my server needs a reboot Also nginx is executed the same way (as an...

Rails test hanging - how can I print the test name before execution?

I'm having a test hang in our rails app can't figure out which one (since it hangs and doesn't get to the failure report). I found this blog post http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/ which adds a setup hook to print the test name but when I try to do the same thing it gives me an error saying...

RoR: Creating/Updating: Showing validation errors while preserving previous values

I have a basic model in which i have specified some of the fields to validate the presence of. in the create action in the controller i do the standard: @obj = SomeObject.new(params[:some_obj]) if @obj.save flash[:notice] = "ok" redirect... else flash[:error] = @obj.errors.full_messages.collect { |msg| msg + "<br/>" } redirect ...

Inject data members to an object

This question is based on another question of mine(thankfully answered). So if in a model I have this: def self.find_extended person = Person.find(:first) complete_name = person.firstname + ', ' + person.lastname return person end How can I inject complete name in the person object so in my controller/view I can access it...

What are some good pop-up dialog boxes for Ruby on Rails

I want to use modal pop-up windows in our web app in Ruby on Rails. Note that I don't want to create a new browser window, but a sub-window inside the existing webpage. We've tried things like TinyBox, but there are issues with returning error information from inside the controller. Any good method or tool that works well in ruby? ...

Composite primary keys versus unique object ID field

I inherited a database built with the idea that composite keys are much more ideal than using a unique object ID field and that when building a database, a single unique ID should never be used as a primary key. Because I was building a Rails from end for this database, I ran into difficulties getting it to conform to the Rails conventi...

Rails Request Initialization

We all hear a lot about scaling issues in Rails. I was just curious what the actual costs in handling a HTTP request is in the Rails framework. Meaning, what has to happen for each and every request which comes in? Is there class parsing? Configuration? Database Connection establishment? ...

Traversing HABTM relationships on ActiveRecord

I'm working on a project for my school on rails (don't worry this is not graded on code) and I'm looking for a clean way to traverse relationships in ActiveRecord. I have ActiveRecord classes called Users, Groups and Assignments. Users and Groups have a HABTM relationship as well as Groups and Assignments. Now what I need is a User func...

Rails Console Doesn't Automatically Load Models For 2nd DB

I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database. database.yml looks like development: adapter: postgresql database: blah blah ... oracle_db: adapter: oracle database: blah blah My models which descend from data on th...

Why ActiveRecord instead of a MySql API

I've been developing web applications for a while and i am quite comfortable with mySql, in fact as many do i use some form of SQL almost every day. I like the syntax and a have zero problems writing queries or optimizing my tables. I have enjoyed this mysql api. The thing that has been bugging me is Ruby on Rails uses ActiveRecord an...

ruby/ruby on rails memory leak detection

I wrote a small web app using ruby on rails, its main purpose is to upload, store, and display results from xml(files can be up to several MB) files. After running for about 2 months I noticed that the mongrel process was using about 4GB of memory. I did some research on debugging ruby memory leaks and could not find much. So I have tw...

Why is Apache + Rails is spitting out two status headers for code 500?

I have a rails app that is working fine except for one thing. When I request something that doesn't exist (i.e. /not_a_controller_or_file.txt) and rails throws a "No Route matches..." exception, the response is this (blank line intentional): HTTP/1.1 200 OK Date: Thu, 02 Oct 2008 10:28:02 GMT Content-Type: text/html Content-Length: 122...

What is a good Ruby on Rails hosting service?

I'm looking to deploy a new Ruby on Rails project I'm working on but need hosting. A managed server is overkill for me. I just need shared space. I'd like to go with a service that specializes in Ruby on Rails. I've looked at SpeedyRails and RailsPlayground and they both seem to have pros and cons. Does anyone have experience with e...

RoR: Model validation question

I have a basic ActiveRecord model in which i have two fields that i would like to validate. The requirement is that at least one of the fields must have a value. Both can have values, but at least one needs a value. How do i express this with validates_presence_of statements? For example: validates_presence_of :main_file validates_...