Hi everybody,
I had generated some migrations files such as
“20080719111013_create_countries.rb” for “countries” table :
class CreateCountries < ActiveRecord::Migration
def self.up
create_table :countries, :force => true do |t|
t.string :name, :null => false, :limit => 80
end
end
def self.down
drop_table :countries
end
end
And now I would like to generate a new file migration for
“arts_countries” table. But I don’t know how to write the nice command
with the right convention because this table is composed by arts and
countries tables (so there isn’t any model)…
Thanks for every ideas.
Zhang’
Zangief I. wrote:
… I would like to generate a new file migration for
“arts_countries” table…
Thanks for every ideas.
Zhang’
ruby script/generate migration CreateArtsCountries
but,
really,
I’d probably create a model too.
ruby script/generate model ArtsCountries art_id:integer
country_id:integer
Hi –
On Sun, 20 Jul 2008, Matthew R. Jacobs wrote:
but,
really,
I’d probably create a model too.
ruby script/generate model ArtsCountries art_id:integer
country_id:integer
I definitely wouldn’t. Those habtm tables really aren’t supposed to be
modeled on the Ruby side. There’s no such thing as “an ArtsCountries”.
David
–
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails July 21-24 Edison, NJ
Advancing With Rails August 18-21 Edison, NJ
See http://www.rubypal.com for details and updates!
David A. Black wrote:
Hi –
On Sun, 20 Jul 2008, Matthew R. Jacobs wrote:
but,
really,
I’d probably create a model too.
ruby script/generate model ArtsCountries art_id:integer
country_id:integer
I definitely wouldn’t. Those habtm tables really aren’t supposed to be
modeled on the Ruby side. There’s no such thing as “an ArtsCountries”.
But that’s probably just a reason to choose a better name.
But given I don’t know what Arts we’re talking about, I can’t suggest
one.
In my experience, most things that start off being a
has_and_belongs_to_many end up becoming a has_many :through,
and as such, already having a well named join in beneficial.
Thanks! That working perfectly 
Hi –
On Sun, 20 Jul 2008, Matthew R. Jacobs wrote:
ruby script/generate model ArtsCountries art_id:integer
has_and_belongs_to_many end up becoming a has_many :through,
and as such, already having a well named join in beneficial.
Of course if you want to create a model and do :through, that’s fine.
I was referring specifically to habtm tables, which should not be
modeled.
David
–
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails July 21-24 Edison, NJ
- Advancing With Rails August 18-21 Edison, NJ
- Co-taught by D.A. Black and Erik Kastner
See http://www.rubypal.com for details and updates!