Hi, I actually have this on my projects, I still need to make it public, but I was trying to make it more stable first.
The main idea was to be able to add anything inside the brackets, so you could include anything valid as options. The main problem is to use spaces or quotes. rails g migration AddGearsToBicycles gears:integer[default:3 ,limit:10,null:false] In my version, I also create the models (when models are created) using the validations for each parameter, when applicable. Ill try to create an public repo for that in a day or two. On Tue, Dec 2, 2014 at 7:34 PM, Alex Soble <aso...@gmail.com> wrote: > > Good point Mohamed -- thanks for noticing that! > > And thanks for the encouragement Rodrigo and Austin. > > On Tuesday, December 2, 2014 8:58:01 AM UTC-6, Mohamed Wael Khobalatte > wrote: >> >> Sounds good. Keep in mind that you could potentially be dealing with >> dynamic values (such as Date, Time, and co) and also binary data, ltrees, >> and so on. Ideally you want to cover all these types, which is prehaps why >> this was not done in the first place. >> >> On Tue, Dec 2, 2014 at 8:22 AM, Austin Story <lonnie...@gmail.com> wrote: >> >>> I like it too. Looks like it would be an easy change as well. >>> >>> On Monday, December 1, 2014 4:18:47 PM UTC-6, Alex Soble wrote: >>>> >>>> Hi Rails core team, >>>> >>>> I've been mulling over an idea for a bit of new syntax, want to hear >>>> what you think about it. >>>> >>>> Two of the most common things I do as a developer when generating a new >>>> migration are (1) add defaults to help avoid nil errors and (2) add indices >>>> to attributes like foreign keys for performance. The migration generator >>>> comes with nice syntax that makes adding indices easy: >>>> >>>> $ bin/rails generate migration AddPartNumberToProducts part_number: >>>> string:index >>>> >>>> (from http://guides.rubyonrails.org/migrations.html# >>>> creating-a-standalone-migration) >>>> >>>> But there's no corresponding syntax for adding defaults. You generate >>>> the migration, find the generated file, add defaults by hand and then run >>>> the migration. What about a way to add defaults to new migrations from the >>>> command line? Could look like this: >>>> >>>> rails g migration AddGearsToBicycles gears:integer[default:3] >>>> >>>> Or in a new model: >>>> >>>> rails g model Bicycle mileage:integer[default:0] gears:integer[default: >>>> 3] >>>> >>>> Improvements or suggestions on the proposed syntax? Any feedback would >>>> be much appreciated! Thanks everyone. >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to rubyonrails-co...@googlegroups.com. >>> To post to this group, send email to rubyonra...@googlegroups.com. >>> Visit this group at http://groups.google.com/group/rubyonrails-core. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Mohamed Wael Khobalatte >> >> -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- Att, Everton http://www.evertonmoreth.com.br -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.