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

expert

How To Use Two Databases Into A Single Application?

junior

What do you mean by the term Scaffolding and what sort of advantages the Ruby can offer when it comes to same?

junior

Mention what is the role of Rails Controller?

Bình luận

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

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