Aliasing a table in ActiveRecord

Assuming I can’t rename my MySQL tables, how would I modify a model so
that it’s called one thing but references a table of a completely
different name. For example:

class Recipe < ActiveRecord::Base

# The actual table is called "FoodInstructions", but I don't want to 

use that.

end

class HomeController < ApplicationController

def index

	@Recipe = Recipes.find_all

end

end

Never mind. I finally figured out how to search for what I needed and I
found the answer in another post.

On Aug 11, 2006, at 1:35 PM, MenDAKE wrote:

class Recipe < ActiveRecord::Base

The actual table is called “FoodInstructions”, but I don’t want to

use that.

end

class Recipe < ActiveRecord::Base

 set_table_name "FoodInstructions"

end

-Ezra

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs