If you are using the Rails 4.x you can now generate migrations with references, like this:
rails generate migration AddUserRefToProducts user:references
like you can see on rails guides
More Related Contents:
- How to do a LIKE query in Arel and Rails?
- ActiveRecord Query Union
- How do I replace accented Latin characters in Ruby?
- How to chain scope queries with OR instead of AND?
- Alias for column names in Rails
- Clean way to find ActiveRecord objects by id in the order specified
- Altering the primary key in Rails to be a string
- What does inverse_of do? What SQL does it generate?
- Rails 3 devise, current_user is not accessible in a Model ?
- LEFT OUTER joins in Rails 3
- Overriding id on create in ActiveRecord
- How do i work with two different databases in rails with active records?
- How to execute a raw update sql with dynamic binding in rails
- Rails 3 – select with Include?
- How do I handle too long index names in a Ruby on Rails ActiveRecord migration?
- Using Rails Migration on different database than standard “production” or “development”
- rails dates with json
- How do you discover model attributes in Rails?
- What’s the difference between belongs_to and has_one?
- How can I rollback a specific migration?
- Renaming the created_at, updated_at columns of ActiveRecord/Rails
- How do rails association methods work?
- Grouping by week/month/etc & ActiveRecord?
- How to use long id in Rails applications?
- Rails 3.1 limit user created objects
- How to show SQL queries run in the Rails console?
- Rails: Overriding ActiveRecord association method
- How do I avoid a race condition in my Rails app?
- Specifying column name in a “references” migration
- How do I add some inserts in rails migration?