Hello, I want to change some tablenames on my DB, but I dont want to change the modelnames in my RailsApp. So I write down this line of code in the model with the changed table: " set_table_name "newName" " . Also I changed in the migrationfiles the tablenames and renamed the fixtures. But if I now run " rake db:fixtures:load " I get an MySql Error: Mysql::Error: Unknown column ''foo'' in ''field list'': INSERT INTO `newTablename` (`price`, `name`, `size`, `type`, `description`, `provider`) VALUES (5.95, ''Pinot Grigio'', ''0.75l'', ''wein'', NULL, ''joeys'') Can anybody tell me what I do wrong? -- 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-/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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 December 2010 09:09, Basti Schenk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > I want to change some tablenames on my DB, but I dont want to change the > modelnames in my RailsApp. So I write down this line of code in the > model with the changed table: " set_table_name "newName" " . Also I > changed in the migrationfiles the tablenames and renamed the fixtures. > > But if I now run " rake db:fixtures:load " I get an MySql Error: > > Mysql::Error: Unknown column ''foo'' in ''field list'': INSERT INTO > `newTablename` (`price`, `name`, `size`, `type`, `description`, > `provider`) VALUES (5.95, ''Pinot Grigio'', ''0.75l'', ''wein'', NULL, > ''joeys'')Is that literally exactly what you get? column ''foo''? and ''newTableName''? If not can you show exactly what it says? I also have country, rating, and buy_again in my wine list, though I doubt if that is part your problem. :) Colin -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
My old tablename was products and sizes. Now it''s fos_products and fos_sizes. I write "set_table_name fos_products" and "set_table_name fos_sizes"in my products and sizes model. After that I renamed my fixture files from products.yml and sizes.yml to fos_products.yml and fos_sizes.yml and I renamed in my migration files the "create table products" statement to "create table fos_products" etc. Now I dropped the DB-> after that rake:db:create->rake db:migrate->rake:db:fixtures:load Mysql::Error: Unknown column ''size'' in ''field list'': INSERT INTO `fos_products` (`price`, `name`, `size`, `type`, `description`, `provider`) VALUES (5.95, ''Pinot Grigio'', ''0.75l'', ''wein'', NULL, ''joeys'') -- 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-/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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 December 2010 10:50, Basti Schenk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> My old tablename was products and sizes. Now it''s fos_products and > fos_sizes. > I write "set_table_name fos_products" and "set_table_name fos_sizes"in > my products and sizes model. > > After that I renamed my fixture files from products.yml and sizes.yml to > fos_products.yml and fos_sizes.yml and I renamed in my migration files > the "create table products" statement to "create table fos_products" > etc. > > Now I dropped the DB-> after that rake:db:create->rake > db:migrate->rake:db:fixtures:load > > Mysql::Error: Unknown column ''size'' in ''field list'': > INSERT INTO `fos_products` (`price`, `name`, `size`, `type`, > `description`, `provider`) VALUES (5.95, ''Pinot Grigio'', ''0.75l'', > ''wein'', NULL, ''joeys'')Can you post db/schema.rb please so we can see what fields are in the table. Just the bit of the schema for fos_products table. Colin -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
#schema.rb ActiveRecord::Schema.define(:version => 20101124114645) do ... create_table "fos_products", :force => true do |t| t.string "name" t.decimal "price", :precision => 8, :scale => 2 t.string "description" t.integer "type_id" t.integer "size_id" t.integer "provider_id" t.date "valid_date" t.integer "card_nr" t.integer "card_char" t.datetime "created_at" t.datetime "updated_at" t.boolean "inactive", :default => false t.integer "editor" 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-/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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 December 2010 11:35, Basti Schenk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> #schema.rb > > ActiveRecord::Schema.define(:version => 20101124114645) do > ... > create_table "fos_products", :force => true do |t| > t.string "name" > t.decimal "price", :precision => 8, :scale => 2 > t.string "description" > t.integer "type_id" > t.integer "size_id" > t.integer "provider_id" > t.date "valid_date" > t.integer "card_nr" > t.integer "card_char" > t.datetime "created_at" > t.datetime "updated_at" > t.boolean "inactive", :default => false > t.integer "editor" > end > ... > endSo what do you deduce from that? Your fixtures load is trying to write to a size field, yet there is no such field, only a size_id. Do I deduce that you have a sizes class with Product belongs_to size, and in the fixtures you are trying to set a particular size value into the fos_products table using the association? If so then this does not seem to work with non-standard table names. Whether there is a way round this I do not know. The best solution is to chuck the fixtures in the bin and move over to Factories, probably Machinist or Factory Girl. I prefer the former. Once you work out how to use them you will not regret the move. If you just want to get it going immediately then I suggest reverting to the manual method for setting size_id, by providing a number for it and for the entries in the sizes table. I guess there are only a couple of sizes so this should not be a problem. A few global search/replace operations in the fixtures should do it. Of course this paragraph started with an ''if'' so it may not be this at all. Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I do this: "I suggest reverting to the manual method for setting size_id, by providing a number for it and for the entries in the sizes table. " Its not nice but it works^^ -- 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-/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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 December 2010 12:08, Basti Schenk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I do this: "I suggest reverting to the manual method for > setting size_id, by providing a number for it and for the entries in > the sizes table. " > > Its not nice but it works^^Fixtures are not nice even when they work. Maintenance is a nightmare. As soon as you have got it all working again then move over to Factories. The time you have wasted with this problem would have been enough to have made the switch. Finally just a note about the changes you made, you said you adjusted the previous migrations so that running from scratch gave you the new table names. A better way would just have been to add a new migration that renamed the table. Colin -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.