Ruby on Rails Monday, August 12, 2013

On 12 August 2013 16:26, Valentin Kotelnitski <lists@ruby-forum.com> wrote:
> hi!
>
> i am trying to add database field to a model without model regeneration.
> i have added my field to migration scripts
>
> class CreateUsers < ActiveRecord::Migration
> def change
> create_table :users do |t|
> t.string :name
> t.string :lg, :default => "en"
> t.timestamps
> end
> end
> end
>
> field :lg
>
> and now need to add this field as a property of "user" model
> how should i do it by hands, just adding a line of code, without model
> regenaration

I don't know what you mean by model regeneration, but if you just want
to add a field to an existing table you should create a new migration
to add that field. You should never change the code in a migration
that has already been run.

Colin

>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/31f262b4a14461c3a3cab958a5e50c7e%40ruby-forum.com?hl=en-US.
> 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtb7sqm0K7u90skmo2GwEhR97ycEynFM5XaMjV5LxbDBw%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment