Hi all, I''m trying to set up my test fixtures, and I''ve recently added foreign keys to my database. Each "channel" is owned by a user, so I need to include a valid user id with each fixture. I''m not sure how to set this up. My YAML is the following eBay: id: 1 name: eBay created_at: <%= 5.days.ago.to_s :db %> user_id: <%= User.find_by_login("quentin") %> antiqueStore: id: 2 name: antique Store created_at: <%= 5.days.ago.to_s :db %> user_id: <%= User.find_by_login("quentin") %> Nothing is inserted into the user table, so the above obviously won''t work. How can I run my users.yaml file when I run my channels test? Thanks, Todd --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Todd Nine wrote:> Hi all, > I''m trying to set up my test fixtures, and I''ve recently added foreign > keys to my database. Each "channel" is owned by a user, so I need to > include a valid user id with each fixture. I''m not sure how to set this > up. My YAML is the following > > eBay: > id: 1 > name: eBay > created_at: <%= 5.days.ago.to_s :db %> > user_id: <%= User.find_by_login("quentin") %> > antiqueStore: > id: 2 > name: antique Store > created_at: <%= 5.days.ago.to_s :db %> > user_id: <%= User.find_by_login("quentin") %>You have a users.yaml file? If not, you need one! Usually the user_id:... lines would read user_id: 4 # some definite number where you have a user in the users.yaml file with id 4 (or some other definite number).> > Nothing is inserted into the user table, so the above obviously won''t > work. > How can I run my users.yaml file when I run my channels test?See http://alistairisrael.wordpress.com/2007/07/27/bootstrapping-your-database-with-ordered-fixtures/>> Thanks, > Todd-- 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 -~----------~----~----~----~------~----~------~--~---
On Oct 9, 2007, at 3:55 PM, Stephan Wehner wrote:> Todd Nine wrote: >> Hi all, >> I''m trying to set up my test fixtures, and I''ve recently added >> foreign >> keys to my database. Each "channel" is owned by a user, so I need to >> include a valid user id with each fixture. I''m not sure how to >> set this >> up. My YAML is the following >> >> eBay: >> id: 1 >> name: eBay >> created_at: <%= 5.days.ago.to_s :db %> >> user_id: <%= User.find_by_login("quentin") %> >> antiqueStore: >> id: 2 >> name: antique Store >> created_at: <%= 5.days.ago.to_s :db %> >> user_id: <%= User.find_by_login("quentin") %> > > You have a users.yaml file? If not, you need one! > > Usually the user_id:... lines would read > > user_id: 4 # some definite number > > where you have a user in the users.yaml file with id 4 (or some other > definite number). > >> Nothing is inserted into the user table, so the above obviously won''t >> work. >> How can I run my users.yaml file when I run my channels test? > > See > http://alistairisrael.wordpress.com/2007/07/27/bootstrapping-your- > database-with-ordered-fixtures/ > >> Thanks, >> ToddWell, you said you''ve added the foreign keys *to the database* so you may have issues with the order in which your fixtures are loaded. If you just need to have the entries of a single fixture loaded to the database in a particular order, you can replace the default YAML map with an omap (ordered map) type quite easily: --- !omap - eBay: id: 1 name: eBay created_at: <%= 5.days.ago.to_s :db %> user_id: 4 - antiqueStore: id: 2 name: antique Store created_at: <%= 5.days.ago.to_s :db %> user_id: 5 But you still (potentially) have the issue of loading the users table before your channels. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Stephan, Thanks for the response, I apologize for the delay in my response, I only have time to work on RoR on the weekends. I do have a users file. I have included the text below. As far as ordering, will the ordering plugin be implicitly executed when I run my rake file, or will I have to manually run the target? Thanks, Todd quentin: id: 1 login: quentin email: quentin-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test #crypted_password: "ce2/iFrNtQ8=\n" # quentin, use only if you''re using 2-way encryption created_at: <%= 5.days.ago.to_s :db %> activated_at: <%= 5.days.ago.to_s :db %> # only if you''re activating new signups enabled: <%= true %> aaron: id: 2 login: aaron email: aaron-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test activation_code: aaronscode # only if you''re activating new signups created_at: <%= 1.days.ago.to_s :db %> enabled: <%= true %> disabled: id: 3 login: disabled email: disabled-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test #crypted_password: "ce2/iFrNtQ8=\n" # quentin, use only if you''re using 2-way encryption created_at: <%= 5.days.ago.to_s :db %> activated_at: <%= 5.days.ago.to_s :db %> # only if you''re activating new signups enabled: <%= false %> On 10/10/07, Stephan Wehner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Todd Nine wrote: > > Hi all, > > I''m trying to set up my test fixtures, and I''ve recently added foreign > > keys to my database. Each "channel" is owned by a user, so I need to > > include a valid user id with each fixture. I''m not sure how to set this > > up. My YAML is the following > > > > eBay: > > id: 1 > > name: eBay > > created_at: <%= 5.days.ago.to_s :db %> > > user_id: <%= User.find_by_login("quentin") %> > > antiqueStore: > > id: 2 > > name: antique Store > > created_at: <%= 5.days.ago.to_s :db %> > > user_id: <%= User.find_by_login("quentin") %> > > > You have a users.yaml file? If not, you need one! > > Usually the user_id:... lines would read > > user_id: 4 # some definite number > > where you have a user in the users.yaml file with id 4 (or some other > definite number). > > > > > Nothing is inserted into the user table, so the above obviously won''t > > work. > > How can I run my users.yaml file when I run my channels test? > > > See > > http://alistairisrael.wordpress.com/2007/07/27/bootstrapping-your-database-with-ordered-fixtures/ > > > > > > Thanks, > > Todd > > -- > 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 -~----------~----~----~----~------~----~------~--~---