ruby-on-rails

Rails model without database

I want to create a Rails (2.1 and 2.2) model with ActiveRecord validations, but without a database table. What is the most widely used approach? I've found some plugins that claim to offer this functionality, but many of them don't appear to be widely used or maintained. What does the community recommend I do? Right now I am leaning ...

RoR: Best way to build 'dashboard' type page?

In the admin section of a website i am building i would like to put together a dashboard page, or 'quick look' type page where the most recent changes/additions/etc in several different areas can be viewed. I was thinking the best way to do this would be to use partials and have each partial contain the markup for the data i need to dis...

RoR: named_scope, all records created within last 7 days?

how do i define a named_scope to return all the records that were created within the last 7 days, and then how do i use that named scope in a controller? ...

How can I have the user create a has_many :through table without any user-input attributes?

I have two models (users and courses) and a JOIN table that allows enrollments in the course: class User < ActiveRecord::Base has_many :enrollments, :dependent => :destroy has_many :courses, :through => :enrollments end class Course < ActiveRecord::Base has_many :enrollments, :dependent => :destroy has_many :users, :throu...

get scriptaculous helper drop_receiving_element to not generate "<script>" tags

Is there a way to get drop_receiving_element to not generate "// .. ...

Ruby on Rails: Why do I get timezones munged when I write a time to the DB, then read it back?

I have config.time_zone in environment.rb set to "UTC", and my mySQL server returns the current time in my local time zone when I issue "select now();" and in utc when I ask for "select utc_timestamp;" I'm running rails 2.1.2, the mysql gem 2.7.3, activerecord gem 2.1.2, and mysql --version returns "Ver 14.12 Distrib 5.0.27 for Win32 (i...

Ruby on Rails and Active Record standalone scripts disagree on database values for :timestamps

I posted a question earlier today when I'd not zeroed in quite so far on the problem. I'll be able to be more concise here. I'm running RoR 2.1.2, on Windows, with MySQL. The SQL server's native time zone is UTC. My local timezone is Pacific (-0800) I have a model with a :timestamp type column which I can do things like this with: ...

Support for foreign key constraint in Rails

In Ruby on Rails, how to add foreign key constraint in migration? ...

Migration files

Where can I download the rails migration file for country, state and city table ...

How to find webrick bugs in NetBeans for Ror?

Hello I'm starting my adventure with Ruby on Rails and as IDE I choose Netbeans. It has bundled server Webrick and it had worked good. But after some changes in my first application it gives me internal error 500 - but nothing shows in console. And older actions give the same result. How can I find where the problem is? I work on Ubuntu...

Rails JOIN TABLES

Hi, I have a following SQL QUERY: SELECT articles.name, articles.price, users.zipcode FROM articles INNER JOIN users ON users.id = articles.user_id WHERE vectors @@ to_tsquery('crime') ORDER BY articles.price ASC And I Would like to write it inside of a find method from an ActiveRecord Class named Articles (Articles belongs_to user). B...

What is Ruby on Rails and why is it so famous?

I have never heard about this language until I came to this site, why is it so famous? Could you post some example sites developed in this technology? Easy with the downvotes please, am nub I know :( Thanks ...

Why do Test::Unit testcases start up so slowly?

>rails -v Rails 1.2.6 >ruby -v ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] When I run a test fixture (that tests a rails model class) like this, it takes 20-30 secs to start executing these tests (show the "Loaded suite..."). What gives? >ruby test\unit\category_test.rb require File.dirname(__FILE__) + '/../test_helper' cla...

backgroundrb thread_pool.defer method logger output goes to where?

It seems like due to the threading issue logger.warn (thats what I tested) doesn't generate any output? my code is similar to this: def deliver(args) logger.info "delivery start" thread_pool.defer(:deliver_deferred, args) logger.info "delivery end" end def deliver_deferred(args) logger.warn "whatsoever" end Any idea? ...

Signaling validation errors in assigning a virtual attribute?

This is a Rails/ActiveRecord question. I have a model which basically has to represent events or performances. Each event has many attributions: an attribution is basically something like "In this event, Person X had Role Y". I concluded that the best way to allow a user to edit this data is by providing a free text field which expects...

Rails JOIN TABLES

Hi, i'm trying to use the GeoKit plugin to calculate the distance between 2 points. So the idea is, i do a search for an article, and the results i want to order by distance. So i have a form where I enter the article (that im looking for) and my address. Then rails must find all articles that match with my query and order by address. S...

Strategy for dealing with large db tables

I'm looking at building a Rails application which will have some pretty large tables with upwards of 500 million rows. To keep things snappy I'm currently looking into how a large table can be split to more manageable chunks. I see that as of MySQL 5.1 there is a partitioning option and that's a possible option but I don't like the wa...

Detect company names that are visiting my site

I'd like to use visitor IP addresses into a company name. This will be used for displaying something like "Hello visitor from Apple Inc." . Note I am looking for the company name, not the domain name. Extra points for determining the originating country. The app is written in Ruby on Rails, but examples in other languages will do. Thanks...

What does "Modify files with subversion/git" mean?

% rails ... General Options: ... -c, --svn Modify files with subversion. (Note: svn must be in path) -g, --git Modify files with git. (Note: git must be in path) What do these "Modify files" options do for me? Edit: It is unclear to me what using one (or both?) of these options actually do...

Rails: calling a model class in a library

I'm trying to verify that a parameter is an instance of a specific class in Rails: def schedule(action, *args) if arg.is_a? Aircraft ... end end I'm doing this in a library class (the file is in lib/) and I get an uninitialized constant Aircraft error. Aircraft is a model class, with a corresponding aircraft.rb file in app/mod...