Govur University Logo
--> --> --> -->
...

Explain the concept of CRUD operations in Ruby on Rails and how they are performed using ActiveRecord.



CRUD is an acronym that stands for Create, Read, Update, and Delete. It represents the basic operations performed on data in a database. In the context of Ruby on Rails, these operations are typically performed using ActiveRecord, the object-relational mapping (ORM) library included in Rails. 1. Create: The create operation involves inserting new records or objects into the database. In Rails, creating a new record involves instantiating a new ActiveRecord model object and assigning values to its attributes. Once the object is created, calling the `save` or `create` method on the object will persist it to the database. For example: ``` ruby`# Create a new instance of a model post = Post.new(title: 'New Post', content: 'Lorem ipsum') # Save the record to the database post.save` ``` 2. Read: The read operation involves retrieving data from....

Log in to view the answer



Community Answers

Sign in to open profiles and full community answers.

No community answers yet. Be the first to submit one.

Redundant Elements