Yitzhak Bar Geva
2007-Jan-02 15:53 UTC
Migration doesn''t load data. How to debug a migration?
We''re learning Rails from the 2nd edition of Agile Web development with Rails under Ubuntu Edgy. I messed up the Ruby and Gem environment but managed to put the pieces together. However, there is one outstanding problem: When running the migrations, they all work, except that the one which loads data (couldn''t attach, theres a bug on the server) does not load the data. before the environment got messed up, it did work OK. It''s funny, because when we run the app. from the browser, data is entered and stored in the database all right. There is no indication in the log files that anything is amiss. Simply the data isn''t written into the DB. Wanted to know if anyone has a hint. Also, how can the migration be debugged? It is run through Rake? Thanks -- 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 -~----------~----~----~----~------~----~------~--~---
Jason Norris
2007-Jan-02 17:33 UTC
Re: Migration doesn''t load data. How to debug a migration?
Sometimes when I can''t figure out what is happening with the database, I put a log on the database and tail it. in /etc/my.cnf: log = /var/log/mysqld.log This will get big fast in production but for development it helps. Jason Yitzhak Bar Geva wrote:> > We''re learning Rails from the 2nd edition of Agile Web development with > Rails under Ubuntu Edgy. > I messed up the Ruby and Gem environment but managed to put the pieces > together. However, there is one outstanding problem: > When running the migrations, they all work, except that the one which > loads data (couldn''t attach, theres a bug on the server) does not load > the data. before the environment got messed up, it did work OK. It''s > funny, because when we run the app. from the browser, data is entered > and stored in the database all right. There is no indication in the log > files that anything is amiss. Simply the data isn''t written into the DB. > Wanted to know if anyone has a hint. Also, how can the migration be > debugged? It is run through Rake? > Thanks >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yitzhak Bar Geva
2007-Jan-02 17:43 UTC
Re: Migration doesn''t load data. How to debug a migration?
Jason Norris wrote:> Sometimes when I can''t figure out what is happening with the database, I > put a log on the database and tail it. > in /etc/my.cnf: > log = /var/log/mysqld.log > This will get big fast in production but for development it helps. > JasonI looked there (I also tried with Sqlite - can''t find it''s log file), but saw nothing relevant. That''s why I wanted to try using the debugger. It''s weird. It worked before I screwed up the Ruby environment. After i restored the Ruby environment, everything works OK, including my other migrations 9which don''t load data. Loading data also works OK, through the web interface of the application. Only loading of data through the migration doesn''t work. here''s the migration (there''s a bug on this forum when trying to attach a file): #--- # Excerpted from "Agile Web Development with Rails, 2nd Ed." # We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information. #--- class AddTestData < ActiveRecord::Migration def self.up Product.create(:title => ''Pragmatic Project Automation'', :description => %{<p> <em>Pragmatic Project Automation</em> shows you how to improve the consistency and repeatability of your project''s procedures using automation to reduce risk and errors. </p> <p> Simply put, we''re going to put this thing called a computer to work for you doing the mundane (but important) project stuff. That means you''ll have more time and energy to do the really exciting---and difficult---stuff, like writing quality code. </p>}, :image_url => ''/images/auto.jpg'', :price => 29.95) Product.create(:title => ''Pragmatic Version Control'', :description => %{<p> This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it''s a foundational piece of any project''s infrastructure. Yet half of all project teams in the U.S. don''t use any version control at all. Many others don''t use it well, and end up experiencing time-consuming problems. </p>}, :image_url => ''/images/svn.jpg'', :price => 28.50) # . . . Product.create(:title => ''Pragmatic Unit Testing (C#)'', :description => %{<p> Pragmatic programmers use feedback to drive their development and personal processes. The most valuable feedback you can get while coding comes from unit testing. </p> <p> Without good tests in place, coding can become a frustrating game of "whack-a-mole." That''s the carnival game where the player strikes at a mechanical mole; it retreats and another mole pops up on the opposite side of the field. The moles pop up and down so fast that you end up flailing your mallet helplessly as the moles continue to pop up where you least expect them. </p>}, :image_url => ''/images/utc.jpg'', :price => 27.75) end def self.down Product.delete_all end end -- 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 -~----------~----~----~----~------~----~------~--~---
I''m having the same exact problem. I downloaded the same code and migration won''t work. I dropped all my data and raked it again and still nothing.> Only loading of data through the > migration doesn''t work. > here''s the migration (there''s a bug on this forum when trying to attach > a file): > #--- > # Excerpted from "Agile Web Development with Rails, 2nd Ed." > # We make no guarantees that this code is fit for any purpose. > # Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book > information. > #----- 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 -~----------~----~----~----~------~----~------~--~---
Yitzhak Bar Geva
2007-Jan-03 00:07 UTC
Re: Migration doesn''t load data. How to debug a migration?
jman wrote:> I''m having the same exact problem. I downloaded the same code and > migration won''t work. I dropped all my data and raked it again and still > nothing. > >> Only loading of data through the >> migration doesn''t work. >> here''s the migration (there''s a bug on this forum when trying to attach >> a file): >> #--- >> # Excerpted from "Agile Web Development with Rails, 2nd Ed." >> # We make no guarantees that this code is fit for any purpose. >> # Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book >> information. >> #---Nice to know that I''m in good company. Know what? I''m going to post this on the one of the relevant Pragmatic Programmers forums/wikis. -- 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 -~----------~----~----~----~------~----~------~--~---
Drew Olson
2007-Jan-04 21:42 UTC
Re: Migration doesn''t load data. How to debug a migration?
Yitzhak Bar Geva wrote:> Nice to know that I''m in good company. Know what? I''m going to post this > on the one of the relevant Pragmatic Programmers forums/wikis.I was having the same problems as well and was able to fix them by updating rails to the absolute newest version, which is the release candidate of Rails 1.2.0. You need this version of Rails in order to follow the examples in the book. -Drew -- 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 -~----------~----~----~----~------~----~------~--~---
Yitzhak Bar Geva
2007-Jan-04 21:56 UTC
Re: Migration doesn''t load data. How to debug a migration?
Drew Olson wrote:> Yitzhak Bar Geva wrote: >> Nice to know that I''m in good company. Know what? I''m going to post this >> on the one of the relevant Pragmatic Programmers forums/wikis. > > I was having the same problems as well and was able to fix them by > updating rails to the absolute newest version, which is the release > candidate of Rails 1.2.0. You need this version of Rails in order to > follow the examples in the book. > > -DrewThanks Drew, In my case, it didn''t solve the problem. I''ll check again to make sure it was the latest version. In any case, I was wondering how one goes about debugging a migration. Yitzhak -- 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 -~----------~----~----~----~------~----~------~--~---