According to ''Agile web development with rails'' "... a model is automatically mapped to a database table whose name is the plural form of the model''s class". Sure enough, when I created migrations for ''Tc_project'', ''Tc_employee'' and ''Tc_period'' the migration files issue a ''create table'' with the table names pluralized. However, when I issue "Rails generate scaffold Tc_data..." the create table statement in the migration DID NOT pluralize ''tc_data'' to ''tc_datas''! Does anyone know if this will create a ''convention'' problem between model and table references for the table ''Tc_data''? Unless I hear otherwise I will assume Rails knows what it is doing and run the migration as-is and proceed as if nothing is out of the ordinary. If Rails chokes on this I will post a reply to my own question. Thanks in advance for any help. Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Rails is smart enough to know that the plural of some words are irregular (examples: category, person) and that some words are "uncountable" (examples: money, information). Since "data" is already the plural form of "datum" I think Rails knows not to make it "datas". You should be good to go. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 18 May 2011 15:37, fredrated <fredp-Sw8Mmj0H/jVYTrM/R70HSA@public.gmane.org> wrote:> According to ''Agile web development with rails'' "... a model is > automatically mapped to a database table whose name is the plural form > of the model''s class". Sure enough, when I created migrations for > ''Tc_project'', ''Tc_employee'' and ''Tc_period'' the migration files issue > a ''create table'' with the table names pluralized. However, when I > issue "Rails generate scaffold Tc_data..." the create table statement > in the migration DID NOT pluralize ''tc_data'' to ''tc_datas''! > > Does anyone know if this will create a ''convention'' problem between > model and table references for the table ''Tc_data''? > Unless I hear otherwise I will assume Rails knows what it is doing and > run the migration as-is and proceed as if nothing is out of the > ordinary. If Rails chokes on this I will post a reply to my own > question.As Tim has pointed out, this should be datum for the singular and data for the plural. I would also point out that you will make life easier for yourself if you stick to the Rails conventions for capitalisation and underscores. In this case the class would be something like TcDatum and the table tc_data (or something completely different if you do not like datum). Similarly I would change the names of the other classes you mention. Colin Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
"you will make life easier for yourself if you stick to the Rails conventions for capitalisation and underscores." Actually I was trying to do that. My boss told me (he is also a newbie) that table names start with a capital letter, though I cannot find documentation to that effect. If you can point me to any references to naming conventions I would appreciate it, thanks. I start each table with "tc_" because I am coming from Drupal where all tables of all modules are in one database and this is necessary to prevent name conflicts. All help is greatly appreciated. -Fred On May 18, 8:32 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 18 May 2011 15:37, fredrated <fr...-Sw8Mmj0H/jVYTrM/R70HSA@public.gmane.org> wrote: > > > According to ''Agile web development with rails'' "... a model is > > automatically mapped to a database table whose name is the plural form > > of the model''s class". Sure enough, when I created migrations for > > ''Tc_project'', ''Tc_employee'' and ''Tc_period'' the migration files issue > > a ''create table'' with the table names pluralized. However, when I > > issue "Rails generate scaffold Tc_data..." the create table statement > > in the migration DID NOT pluralize ''tc_data'' to ''tc_datas''! > > > Does anyone know if this will create a ''convention'' problem between > > model and table references for the table ''Tc_data''? > > Unless I hear otherwise I will assume Rails knows what it is doing and > > run the migration as-is and proceed as if nothing is out of the > > ordinary. If Rails chokes on this I will post a reply to my own > > question. > > As Tim has pointed out, this should be datum for the singular and data > for the plural. I would also point out that you will make life easier > for yourself if you stick to the Rails conventions for capitalisation > and underscores. In this case the class would be something like > TcDatum and the table tc_data (or something completely different if > you do not like datum). Similarly I would change the names of the > other classes you mention. > > Colin > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi All, I want to create an application in order to convert web page in to pdf. like the below I/p => http://www.test.com o/p => pdf file has the content of http://www.test.com page. Is their any plugins available for this option. Thanks in avance Thanks & Regards, Loganathan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wednesday, May 18, 2011 10:56:48 AM UTC-6, fredrated wrote:> > "you will make life easier for yourself if you stick to the Rails > conventions for capitalisation and underscores." > > Actually I was trying to do that. My boss told me (he is also a > newbie) that table names start with a capital letter, though I cannot > find documentation to that effect. > If you can point me to any references to naming conventions I would > appreciate it, thanks. >Table names are all lowercase by convention (and plural). Model names are singular, capitalized CamelCase. In fact, it is a ruby-wide convention that class names are capitalized CamelCase (not just rails).> > I start each table with "tc_" because I am coming from Drupal where > all tables of all modules are in one database and this is necessary to > prevent name conflicts. > >As for having a prefix, you might be interested in the #table_name_prefix property: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-table_name_prefix This would allow you to have tables named: tc_projects tc_employees tc_periods tc_datum And model classes respectively: class Project < ActiveRecord::Base table_name_prefix = "tc_" end ... class Datum < ActiveRecord::Base table_name_prefix = "tc_" end In order to then DRY up your code a bit, you *might* be able to use an abstract base class: class TcPrefix < ActiveRecord::Base table_name_prefix = "tc_" abstract_class = true end class Project < TcPrefix end ... class Datum < TcPrefix end I haven''t tested this to see if this variation works correctly. I''d give a try though. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > > tc_datum > >Woops, table name would be tc_data while the class would be Data (or TcData if you don''t use table_name_prefix). My bad. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wednesday, May 18, 2011 2:22:56 PM UTC-6, Kendall Gifford wrote:> > >> tc_datum >> >> > Woops, table name would be tc_data while the class would be Data (or TcData > if you don''t use table_name_prefix). My bad. >Oh my gosh. I need some sleep and to actually proof-read what I type before I click "Send". Table name: tc_data Model name: Datum or TcDatum (crawling back into my hole...) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.