How do I explicitly specify a Model’s table-name mapping in Rails?

I have a Model class called Countries and I want it to map to a DB table called ‘cc’. How is that done in Rails (3)?

How do I specify the tablename in a filter in Yii?

There’s two tables, attendee, and group. both have a gender field. Each attendee is assigned to 1 group. I’ve got my CGridView successfully showing the number of attendees, but when I added code to fi

How do I specify associations in Rails that pass through several models

I’m writing some tricky polymorphic relationships to handle tagging. I have a Tag model, and a Tagging model which belongs_to a polymorphic taggable. I have an Item model, which has_many :taggings, :a

In Fluent NHibernate how do I specify a dictionary mapping type size?

How can I specify the size of the type used in the following Dictionary mapping: HasMany(x => x.WidgetSettings) .AsMap<string>(idx => idx.Column(SettingKey), elem => elem.Column(Sett

How to do models mapping?

I have one Photo Entity, where I want to save all the photos. I have other entity say User and Post. Both can have multiple photos. It should be a many to many mapping? Am I doing right? I am doing it

How do i explicitly clear the byte[]

I am creating new byte arrays which are not being collected by GC and are living in memory and increasing the private bytes. The code below gets executed every 10 seconds. How do I explicitly clear th

How do I specify a version of Ruby for Rails without using RVM?

How do I specify a version of Ruby for Rails without using RVM? I am using Xubuntu 11.10, which comes with Ruby 1.8. I have installed Ruby 1.9 package, and updated the alternatives so ruby -version re

How do I explicitly specify where a Nancy view is located?

First of all I know what the problem is, I just don’t know Nancy well enough to know how to fix it. I have a unit test failing when as part of the appharbor build process. The same test also fails whe

Rails: How do I reset models and migrations?

I’ve been working with Rails and of course have learned quite a bit since I started. I’m wanting to keep a lot of my files I’ve made but I’m wanting to recreate many of my models. Since I wasn’t conce

Mapping entities to dynamic tablename

I want to create a hibernate mapping to a data-source with dynamic tablenames. The tables reflect datasets extracted from another source by a legacy tool, and the tablename itself carries meta-informa

show create table tablename (how do i do this in sql server)?

in mysql it is possible to do show create table tablename what is the sql server equivalent?


Rails >= 3.2 (including Rails 4+):

class Countries < ActiveRecord::Base
  self.table_name = "cc"

Rails <= 3.1:

class Countries < ActiveRecord::Base
  self.set_table_name "cc"
class Countries < ActiveRecord::Base
    self.table_name = "cc"

In Rails 3.x this is the way to specify the table name.