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

junior

What Is MVC? And How It Works?

junior

What Do You Mean By Render And Redirect_to ?

junior

Explain how you define Instance Variable, Global Variable and Class Variable in Ruby?

Bình luận

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

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