I’ll use StackOverflow as my example. Let’s say I have a Question model. A logged in user can “star” a Question to mark is as one of their favorites. In the database, this sort of thing would probably be stored in a UserQuestions table with a user_id field and a question_id field. This sort of feature is not typical CRUD since there is really only “list”, “add”, and “delete”. Also the records being displayed on the “User starred questions” list should be not UserQuestion records but instead Question records. What code do I put in my controller and UserQuestion model?
class MyFavoriteQuestionsController < ApplicationController
def index
#list just the questions associated with current_user
end
def add
#insert a row in the database for current_user and selected question
def
def remove
#remove the row from the database
end
end
I’d say this is typical crud if you stick with convention. Add is create, remove is destroy.