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'' -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Zangief Ief 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi -- On Sun, 20 Jul 2008, Matthew Rudy Jacobs wrote:> > Zangief Ief 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:integerI 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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks! That working perfectly :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David A. Black wrote:> Hi -- > > On Sun, 20 Jul 2008, Matthew Rudy 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi -- On Sun, 20 Jul 2008, Matthew Rudy Jacobs wrote:> > David A. Black wrote: >> Hi -- >> >> On Sun, 20 Jul 2008, Matthew Rudy 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.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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---