Hello, I try to add a column named id_category to my database table berichten. So I have this : class Bericht < ActiveRecord::Migration def up add_column :berichten do [t] t.column :name, ''id_category'' end end def down end end But I get wrong number ( 1 of 3 ) error message. Can anyone tell me what''s wrong here so I can learn to write my own migrations. Roelof -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/_J0oNDSxy9QJ. For more options, visit https://groups.google.com/groups/opt_out.
you have to create a new migration for add_column using rails g migration col_name_table_name in that migration file you have to follow below syntax def up add_column : table_name, column_name, data_type end i hope its help to you.. On Tue, Oct 23, 2012 at 8:19 PM, roelof <rwobben-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Hello, > > I try to add a column named id_category to my database table berichten. > So I have this : > > class Bericht < ActiveRecord::Migration > def up > add_column :berichten do [t] > t.column :name, ''id_category'' > end > end > def down > end > end > > But I get wrong number ( 1 of 3 ) error message. > > Can anyone tell me what''s wrong here so I can learn to write my own > migrations. > > Roelof > > -- > 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 > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/_J0oNDSxy9QJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 https://groups.google.com/groups/opt_out.
Sorry I dont help me I did rails g migration id_category bericht And changed the migration file to this class IdCategory < ActiveRecord::Migration def up add_column :bericht, id_category, number end def down end end After that I did rake db:migrate and get this output : == IdCategory: migrating ====================================================-- id_category() rake aborted! An error has occurred, this and all later migrations canceled: undefined local variable or method `id_category'' for #<IdCategory:0x00000004c3f0d8> Tasks: TOP => db:migrate (See full trace by running task with --trace) Roelof Op dinsdag 23 oktober 2012 16:56:42 UTC+2 schreef BalaRaju Vankala het volgende:> > you have to create a new migration for add_column > using rails g migration col_name_table_name > in that migration file you have to follow below syntax > > > def up > add_column : table_name, column_name, data_type > end > > i hope its help to you.. > On Tue, Oct 23, 2012 at 8:19 PM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org <javascript:>>wrote: > >> Hello, >> >> I try to add a column named id_category to my database table berichten. >> So I have this : >> >> class Bericht < ActiveRecord::Migration >> def up >> add_column :berichten do [t] >> t.column :name, ''id_category'' >> end >> end >> def down >> end >> end >> >> But I get wrong number ( 1 of 3 ) error message. >> >> Can anyone tell me what''s wrong here so I can learn to write my own >> migrations. >> >> Roelof >> >> -- >> 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 rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:> >> . >> To unsubscribe from this group, send email to >> rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/_J0oNDSxy9QJ. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > > > >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Y-uT61sr6GoJ. For more options, visit https://groups.google.com/groups/opt_out.
Op dinsdag 23 oktober 2012 17:03:29 UTC+2 schreef roelof het volgende:> > Sorry I dont help me > > I did rails g migration id_category bericht > And changed the migration file to this > > class IdCategory < ActiveRecord::Migration > def up > add_column :bericht, id_category, number > end > > def down > end > end > > After that I did rake db:migrate and get this output : > > == IdCategory: migrating > ====================================================> -- id_category() > rake aborted! > An error has occurred, this and all later migrations canceled: > > undefined local variable or method `id_category'' for > #<IdCategory:0x00000004c3f0d8> > > Tasks: TOP => db:migrate > (See full trace by running task with --trace) > > Roelof > > > > Op dinsdag 23 oktober 2012 16:56:42 UTC+2 schreef BalaRaju Vankala het > volgende: >> >> you have to create a new migration for add_column >> using rails g migration col_name_table_name >> in that migration file you have to follow below syntax >> >> >> def up >> add_column : table_name, column_name, data_type >> end >> >> i hope its help to you.. >> On Tue, Oct 23, 2012 at 8:19 PM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: >> >>> Hello, >>> >>> I try to add a column named id_category to my database table berichten. >>> So I have this : >>> >>> class Bericht < ActiveRecord::Migration >>> def up >>> add_column :berichten do [t] >>> t.column :name, ''id_category'' >>> end >>> end >>> def down >>> end >>> end >>> >>> But I get wrong number ( 1 of 3 ) error message. >>> >>> Can anyone tell me what''s wrong here so I can learn to write my own >>> migrations. >>> >>> Roelof >>> >>> -- >>> 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 rubyonra...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/rubyonrails-talk/-/_J0oNDSxy9QJ. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> >> >> >>-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/TyN7jLX_NjYJ. For more options, visit https://groups.google.com/groups/opt_out.
You need something like class IdCategory < ActiveRecord::Migration def up add_column :bericht, ''id_category'', :integer end def down end end You can use either strings or symbols. Norm On 10/23/2012 08:03 AM, roelof wrote:> Sorry I dont help me > > I did rails g migration id_category bericht > And changed the migration file to this > > class IdCategory < ActiveRecord::Migration > def up > add_column :bericht, id_category, number > end > > def down > end > end > > After that I did rake db:migrate and get this output : > > == IdCategory: migrating > ====================================================> -- id_category() > rake aborted! > An error has occurred, this and all later migrations canceled: > > undefined local variable or method `id_category'' for > #<IdCategory:0x00000004c3f0d8> > > Tasks: TOP => db:migrate > (See full trace by running task with --trace) > > Roelof > > > > Op dinsdag 23 oktober 2012 16:56:42 UTC+2 schreef BalaRaju Vankala het > volgende: > > you have to create a new migration for add_column > using rails g migration col_name_table_name > in that migration file you have to follow below syntax > > > def up > add_column : table_name, column_name, data_type > end > > i hope its help to you.. > On Tue, Oct 23, 2012 at 8:19 PM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > <javascript:>> wrote: > > Hello, > > I try to add a column named id_category to my database table > berichten. > So I have this : > > class Bericht < ActiveRecord::Migration > def up > add_column :berichten do [t] > t.column :name, ''id_category'' > end > end > def down > end > end > > But I get wrong number ( 1 of 3 ) error message. > > Can anyone tell me what''s wrong here so I can learn to write > my own migrations. > > Roelof > > -- > 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 > rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > To unsubscribe from this group, send email to > rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/_J0oNDSxy9QJ <https://groups.google.com/d/msg/rubyonrails-talk/-/_J0oNDSxy9QJ>. > For more options, visit > https://groups.google.com/groups/opt_out > <https://groups.google.com/groups/opt_out>. > > > > > > > > > -- > 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 > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/Y-uT61sr6GoJ. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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 https://groups.google.com/groups/opt_out.
Thanks. Another problem solved. Roelof Op dinsdag 23 oktober 2012 17:10:51 UTC+2 schreef Norm het volgende:> > You need something like > > class IdCategory < ActiveRecord::Migration > def up > add_column :bericht, ''id_category'', :integer > end > > def down > end > end > > You can use either strings or symbols. > > Norm > > On 10/23/2012 08:03 AM, roelof wrote: > > Sorry I dont help me > > I did rails g migration id_category bericht > And changed the migration file to this > > class IdCategory < ActiveRecord::Migration > def up > add_column :bericht, id_category, number > end > > def down > end > end > > After that I did rake db:migrate and get this output : > > == IdCategory: migrating > ====================================================> -- id_category() > rake aborted! > An error has occurred, this and all later migrations canceled: > > undefined local variable or method `id_category'' for > #<IdCategory:0x00000004c3f0d8> > > Tasks: TOP => db:migrate > (See full trace by running task with --trace) > > Roelof > > > > Op dinsdag 23 oktober 2012 16:56:42 UTC+2 schreef BalaRaju Vankala het > volgende: >> >> you have to create a new migration for add_column >> using rails g migration col_name_table_name >> in that migration file you have to follow below syntax >> >> >> def up >> add_column : table_name, column_name, data_type >> end >> >> i hope its help to you.. >> On Tue, Oct 23, 2012 at 8:19 PM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: >> >>> Hello, >>> >>> I try to add a column named id_category to my database table berichten. >>> So I have this : >>> >>> class Bericht < ActiveRecord::Migration >>> def up >>> add_column :berichten do [t] >>> t.column :name, ''id_category'' >>> end >>> end >>> def down >>> end >>> end >>> >>> But I get wrong number ( 1 of 3 ) error message. >>> >>> Can anyone tell me what''s wrong here so I can learn to write my own >>> migrations. >>> >>> Roelof >>> >>> -- >>> 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 rubyonra...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/rubyonrails-talk/-/_J0oNDSxy9QJ. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> >> >> >> -- > 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 rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:> > . > To unsubscribe from this group, send email to > rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/Y-uT61sr6GoJ. > For more options, visit https://groups.google.com/groups/opt_out. > > > > >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Hwaez3v2qoIJ. For more options, visit https://groups.google.com/groups/opt_out.