Câu hỏi phỏng vấn Ruby on Rails
Câu hỏi

List out what can Rails Migration do?

Câu trả lời

Rails migrations allow you to evolve your database schema over time using Ruby code instead of writing raw SQL. Here are some key things that Rails migrations can do:

  • Create new tables with specified columns and data types[1][2]. For example:
ruby Copy
create_table :products do |t|
  t.string :name
  t.string :part_number
  t.timestamps
end
  • Add, remove, or change columns in existing tables[1]. For example:
ruby Copy
add_column :products, :description, :text
remove_column :products, :part_number
  • Create associations between tables using references or belongs_to[1]. For example:
ruby Copy
add_reference :products, :user, foreign_key: true
  • Create join tables for many-to-many associations[1]. For example:
ruby Copy
create_join_table :customers, :products
  • Run arbitrary SQL statements[1]

  • Undo migrations if needed[1]

  • Provide a consi...

junior

junior

Gợi ý câu hỏi phỏng vấn

middle

What is the difference between symbol and string ?

expert

What sort of problems you have faced with Ruby on Rails and how do you think the same can affect the
projects?

middle

What exactly are Harnesses and Fixtures in the Ruby?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào