Fred,

You made me think I might have run the migration prematurely.  So far, all 
examples in the book have worked perfectly (I can't say that for many 
books!) so it might be a layer 8 issue....  I don't remember running it 
before I updated the migration file, but it's possible.  If the 
t.references should work, I'm happy to know that at least.  I'll go back 
and run through another test to see if it gets the same results.

Thanks

On Saturday, January 25, 2014 8:59:30 AM UTC-5, Frederick Cheung wrote:
>
> On Friday, January 24, 2014 7:25:02 PM UTC+1, Martin Sloan wrote: 
> > Hello, 
> > 
> > 
> > 
> > My issue is that after I migrate this file, when I try to make an 
> association between the article and category object (article.categories << 
> category) it spits an error that article_id does not exist in 
> articles_categories table.  It makes sense to me since the references above 
> do no have _id appended in the class.  If I change the class to the 
> following, creating the relationship between article and category works 
> fine: 
> > 
>
> That should work - t.references should add the _id to the column name for 
> you. What columns did this add? Are you sure you didn't run the migration 
> before you had finished editing it? 
>
> Fred 
>
>
> > 
> > 
> > class CreateArticlesCategories < ActiveRecord::Migration 
> > 
> >   def change 
> > 
> >     create_table :articles_categories, :id=> false do |t| 
> > 
> >       t.integer :article_id 
> > 
> >       t.integer :category_id 
> > 
> >     end 
> > 
> >   end 
> > 
> >   def self.down 
> > 
> >     drop_table :articles_categories 
> > 
> >   end 
> > 
> > end 
> > 
> > 
> > My question is, how can I get the 't.references' format to work so that 
> AR looks for an 'articles' and 'categories' column, instead of the same 
> with _id appended? 
> > 
> > 
> > Thanks 
>
>

-- 
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+unsubscr...@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/0466cd57-3e3c-4fde-a81c-dcb259d43614%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to