I like the simplicity and elegance of creating a new associated object with:
@todo = @current_user.todos.build(params[:todo])
@todo = Todo.new(params[:todo])
@todo.user = @current_user
But isn’t the first solution inherently slower since ‘todos’ makes a call to the database first and return all Todo objects for @current_user?
Same with ‘find’ on a collection. That is, isn’t
@todo = @current_user.todos.find(params[:id])
much slower than
@todo = Todo.find_by_id_and_user_id(params[:id], @current_user.id) ?
Thanks. I’m very interested in finding out why one method is preferred over the other.