I have: class CreateGuests < ActiveRecord::Migration def self.up create_table :guests do |t| t.string :namen t.text :comment t.integer :admin, :default => 0 t.integer :deleted, :default => 1 t.timestamps end Guest.create(:namen => "aaa, :comment => "bbb", :admin => 1, :deleted => 0) end def self.down drop_table :guests end end Migration runs fine - "rake db:migrate --trace" gives no errors but the guest is not created! Any hints? PS: I run Rails 2.0.2 Thanx -- Jochen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jochen Kaechelin wrote:> I have: > > class CreateGuests < ActiveRecord::Migration > def self.up > create_table :guests do |t| > t.string :namen > t.text :comment > t.integer :admin, :default => 0 > t.integer :deleted, :default => 1 > t.timestamps > end > > Guest.create(:namen => "aaa, :comment => "bbb", :admin => > 1, :deleted => 0) >You are missing a closing quote on the "aaa -- 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 -~----------~----~----~----~------~----~------~--~---
Jochen Kaechelin
2007-Dec-26 16:49 UTC
Re: create statement in migration file does not work
Am 26.12.2007 um 17:45 schrieb Chris Olsen:> > Jochen Kaechelin wrote: >> I have: >> >> class CreateGuests < ActiveRecord::Migration >> def self.up >> create_table :guests do |t| >> t.string :namen >> t.text :comment >> t.integer :admin, :default => 0 >> t.integer :deleted, :default => 1 >> t.timestamps >> end >> >> Guest.create(:namen => "aaa, :comment => "bbb", :admin => >> 1, :deleted => 0) >> > > You are missing a closing quote on the "aaaUps...I just replaced the real name with "aaa" and forgot the closing quote. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Have you any validation rules that would prevent it being saved? Jochen Kaechelin wrote:> I have: > > class CreateGuests < ActiveRecord::Migration > def self.up > create_table :guests do |t| > t.string :namen > t.text :comment > t.integer :admin, :default => 0 > t.integer :deleted, :default => 1 > t.timestamps > end > > Guest.create(:namen => "aaa, :comment => "bbb", :admin => > 1, :deleted => 0) > > end > > def self.down > drop_table :guests > end > end > > > Migration runs fine - "rake db:migrate --trace" gives no errors but > the guest is not created! > > Any hints? > > PS: I run Rails 2.0.2 > > Thanx > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jochen Kaechelin
2007-Dec-26 17:01 UTC
Re: create statement in migration file does not work
Am 26.12.2007 um 17:56 schrieb John Ward:> > Have you any validation rules that would prevent it being saved?I HAD some: before_validation :trim_strings before_save { |guest| guest.password = md5_pass(guest.password) if guest.not_enabled? } but I disabled them. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jochen Kaechelin wrote:> Am 26.12.2007 um 17:45 schrieb Chris Olsen: > >>> t.integer :deleted, :default => 1 >>> t.timestamps >>> end >>> >>> Guest.create(:namen => "aaa, :comment => "bbb", :admin => >>> 1, :deleted => 0) >>> >> >> You are missing a closing quote on the "aaa > > Ups...I just replaced the real name with "aaa" and forgot the closing > quote.Are you sure that this migration script is running, ie, are you fully re-creating your db before each migration? Are you able to enter the Guest.create(...) from the script/console? -- 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 -~----------~----~----~----~------~----~------~--~---
Jochen Kaechelin
2007-Dec-26 17:23 UTC
Re: create statement in migration file does not work [solved]
Am 26.12.2007 um 18:07 schrieb Chris Olsen:> > Jochen Kaechelin wrote: >> Am 26.12.2007 um 17:45 schrieb Chris Olsen: >> >>>> t.integer :deleted, :default => 1 >>>> t.timestamps >>>> end >>>> >>>> Guest.create(:namen => "aaa, :comment => "bbb", :admin => >>>> 1, :deleted => 0) >>>> >>> >>> You are missing a closing quote on the "aaa >> >> Ups...I just replaced the real name with "aaa" and forgot the closing >> quote. > > Are you sure that this migration script is running,rake db:migrate --trace (in /Users/bullet/Documents/RAILS_WORK/...........) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate == 1 CreateSessions: migrating ===============================================-- create_table(:sessions) -> 0.0042s -- add_index(:sessions, :session_id) -> 0.0408s -- add_index(:sessions, :updated_at) -> 0.0112s == 1 CreateSessions: migrated (0.0566s) ====================================== == 2 CreateGuests: migrating =================================================-- create_table(:guests) -> 0.0124s == 2 CreateGuests: migrated (0.1872s) ======================================== == 5 CreateLogins: migrating =================================================-- create_table(:logins) -> 0.0046s == 5 CreateLogins: migrated (0.0048s) ======================================== == 7 CreateGaleries: migrating ===============================================-- create_table(:galeries) -> 0.0099s == 7 CreateGaleries: migrated (0.0101s) ====================================== == 8 CreatePics: migrating ===================================================-- create_table(:pics) -> 0.0071s == 8 CreatePics: migrated (0.0073s) ========================================== == 9 CreateMessages: migrating ===============================================-- create_table(:messages) -> 0.0056s == 9 CreateMessages: migrated (0.0059s) ====================================== == 10 CreateBookings: migrating ==============================================-- create_table(:bookings) -> 0.0166s == 10 CreateBookings: migrated (0.0167s) ===================================== == 11 CreateAnswers: migrating ===============================================-- create_table(:answers) -> 0.0052s == 11 CreateAnswers: migrated (0.0053s) ====================================== ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump> ie, are you fully re-creating your db before each migration?In this special case here: Yes.> > > Are you able to enter the Guest.create(...) from the script/console?>> g = Guest.new => #<Guest id: nil, salutation: nil, namen: nil, surname: nil, email: nil, telephone: nil, mobile: nil, street: nil, city: nil, zip: nil, password: nil, token: nil, company: nil, comment: nil, admin: 0, deleted: 1, created_at: nil, updated_at: nil> >> g.namen = "aaa" => "aaa" >> g.save => false Uuppps...... I forgot one thing: validates_confirmation_of :password, :message => "Passwörter stimmen nicht überein!", :on => :create so I added :password_confirmation => "bla bla....." to my migration file!! Thanx guys! --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, 26 Dec 2007 17:35:46 +0100, Jochen Kaechelin wrote:> Guest.create(:namen => "aaa, :comment => "bbb", :admin => > 1, :deleted => 0)I didn''t know you could put dummy data directly into the migration -- thanks! -Thufir --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Your admin and deleted fields should be booleans, not integers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jochen Kaechelin
2007-Dec-26 23:19 UTC
Re: create statement in migration file does not work
Am 27.12.2007 um 00:15 schrieb Ryan Bigg:> Your admin and deleted fields should be booleans, not integers.This would not work here, because I need to store more then true or false in this two fields - I think I should find better labels for these fields....perhaps rights and status.... Thanx --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---